@@ -161,4 +161,41 @@ The ``Helper`` has one required method:
161
161
:method: `Symfony\\ Component\\ Templating\\ Helper\\ HelperInterface::getName `.
162
162
This is the name that is used to get the helper from the ``$view `` object.
163
163
164
+ Creating a Custom Engine
165
+ ------------------------
166
+
167
+ Besides providing a PHP templating engine, you can also create your own engine
168
+ using the Templating component. To do that, create a new class which
169
+ implements the :class: `Symfony\\ Component\\ Templating\\ EngineInterface `
170
+ interface. This interface requires 3 method:
171
+
172
+ * :method: `render($name, array $parameters = array()) <Symfony\\ Component\\ Templating\\ EngineInterface::render> `
173
+ - Renders a template
174
+ * :method: `exists($name) <Symfony\\ Component\\ Templating\\ EngineInterface::exists> `
175
+ - Checks if the template exists
176
+ * :method: `supports($name) <Symfony\\ Component\\ Templating\\ EngineInterface::supports> `
177
+ - Checks if the given template can be handled by this engine.
178
+
179
+ Using Multiple Engines
180
+ ----------------------
181
+
182
+ It is possible to use multiple engines at the same time using the
183
+ :class: `Symfony\\ Component\\ Templating\\ DelegatingEngine ` class. This class
184
+ takes a list of engines and acts just like a normal templating engine. The
185
+ only difference is that it delegates the calls to one of the other engines. To
186
+ choose which one to use for the template, the
187
+ :method: `EngineInterface::supports() <Symfony\\ Component\\ Templating\\ EngineInterface::supports> `
188
+ method is used.
189
+
190
+ .. code-block :: php
191
+
192
+ use Acme\Templating\CustomEngine;
193
+ use Symfony\Component\Templating\PhpEngine;
194
+ use Symfony\Component\Templating\DelegatingEngine;
195
+
196
+ $templating = new DelegatingEngine(array(
197
+ new PhpEngine(...),
198
+ new CustomEngine(...)
199
+ ));
200
+
164
201
.. _Packagist : https://packagist.org/packages/symfony/templating
0 commit comments