Differences

This shows you the differences between two versions of the page.

sourceresolver [2016/02/10 22:37]
24.114.56.119
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 ====