This shows you the differences between two versions of the page.
sourceresolver [2010/12/05 14:09] 81.187.95.96 old revision restored |
sourceresolver [2024/05/31 06:09] (current) 104.194.134.81 1 |
||
---|---|---|---|
Line 2: | Line 2: | ||
You can create fake filesystems for PHPTAL templates. This lets you load templates //and macros// from any source, e.g. a database. | You can create fake filesystems for PHPTAL templates. This lets you load templates //and macros// from any source, e.g. a database. | ||
+ | |||
===== Simplest way ===== | ===== Simplest way ===== | ||
Line 7: | Line 8: | ||
If you don't use macros, you don't need ''SourceResolver'': | If you don't use macros, you don't need ''SourceResolver'': | ||
- | $phptal->setSource(load_source_from_anywhere()); // No source resolver necessary | + | $phptal->setSource(load_source_from_anywhere()); // No source resolver necessary |
===== Implementing custom source ===== | ===== Implementing custom source ===== | ||
Line 30: | Line 31: | ||
$phptal->addSourceResolver(new MySourceResolver()); | $phptal->addSourceResolver(new MySourceResolver()); | ||
- | PHPTAL will call ''resolve()'' method whenever it needs to load a template set via ''setTemplate()'' or ''metal:use-macro''. | + | PHPTAL will call ''resolve()'' method whenever it needs to load a template set via ''setTemplate()'' or ''metal:use-macro''. () |
==== Lazy loading of templates ==== | ==== Lazy loading of templates ==== | ||
Line 54: | Line 55: | ||
} | } | ||
- | PHPTAL will call ''getData()'' only when ''getRealPath()'' or ''getLastModifiedTime()'' return different values. | + | PHPTAL will call ''getData()'' only when ''getRealPath()'' or ''getLastModifiedTime()'' return different values.() |