@@ -22,17 +22,20 @@ was previously defined on template engine level. If you have customized this set
2222the ` TemplateEngineFactory ` module's config. Defaults to ` templates/views ` .
2323* _ Chunks_ are now called _ Controllers_ . While the semantics remain the same, the public API has changed. Please
2424read the [ Controllers] ( #controllers ) chapter on how to update your code.
25- * The method ` TemplateEngineFactory::instance() ` ( plus some aliases) do no longer exist. Use
25+ * The method ` TemplateEngineFactory::instance() ` , plus some aliases do no longer exist. Use
2626` TemplateEngineFactory::render() ` to render a given template of the engine.
2727* On template engine level, the confusing ` global_template ` setting does no longer exist. Use the introduced hook
2828` ___resolveTemplate ` to resolve a custom template when a page gets rendered. The default strategy still looks for a template
2929with the same name as the ProcessWire template.
3030
31+ > Make sure to clear the compiled files cache after replacing the module files! Press _ Clear Compiled Files_ at the
32+ bottom when viewing the site's modules in the ProcessWire admin. Or simply delete anything in ` ./site/assets/cache/ ` .
33+
3134## Controllers
3235
3336A _ controller_ wraps a ProcessWire template executing some logic and a template file of the active engine, rendering the
3437output. This is how the _ Automatic page rendering_ feature works, by using the template file of a page as controller. By
35- defining custom controllers, you get the the same functionality:
38+ defining custom controllers, you get the same functionality without depending on a page :
3639
3740``` php
3841$factory = $modules->get('TemplateEngineFactory');
@@ -141,7 +144,31 @@ wire()->addHookAfter('TemplateEngineFactory::shouldRenderPage', function (HookEv
141144
142145## Best Practices
143146
147+ Write me please 😬
148+
144149## Implementing a Template Engine
145150
151+ Adding your favorite template engine to the factory is really easy.
152+
153+ * Each template engine is added via ProcessWire module. This module provides the template engine's configuration and
154+ registers the engine to the factory.
155+ * The engine itself is implemented using the ` TemplateEngineFactory\TemplateEngineInterface ` contract.
156+ * The factory provides an abstract base implementation ` TemplateEngineFactory\TemplateEngineBase ` which your engine
157+ should extend.
158+
159+ For an example, take a look at the [ TemplateEngineTwig] ( https://github.com/wanze/TemplateEngineTwig ) implementation.
160+
146161## Running Tests
147162
163+ The module includes [ PHPUnit] ( https://phpunit.de/ ) based tests cases, located in the ` ./tests ` directory.
164+
165+ * Make sure that the dev dependencies are installed by running ` composer install ` in the ProcessWire root directory.
166+ * The tests will create pages and templates. Everything should get cleaned up properly, but you should not run them
167+ on a production environment 😉.
168+
169+ To run the tests:
170+
171+ ```
172+ vendor/bin/phpunit --bootstrap site/modules/TemplateEngineFactory/tests/bootstrap.php site/modules/TemplateEngineFactory/tests/src
173+ ```
174+
0 commit comments