Brings Twig template engine support for Fwk\Core Applications.
Via Composer:
{
"require": {
"nitronet/fwk-twig": "dev-master",
}
}
If you don't use Composer, you can still download this repository and add it
to your include_path
PSR-0 compatible
Define a Twig_Environment
instance in your Di Container, and configure it the way you want:
<!-- Twig_Environment Configuration -->
<array-definition name="twig.config">
<param key="debug">true</param>
</array-definition>
<!-- Twig_Loader definition -->
<class-definition name="twig.loader" class="\Twig_Loader_Filesystem" shared="true">
<!-- :packageDir = directory of this .xml file -->
<argument>:packageDir/path/to/templates</argument>
</class-definition>
<!-- Twig_Environment definition -->
<class-definition name="twig" class="\Twig_Environment" shared="true">
<argument>@twig.loader</argument>
<argument>@twig.config</argument>
</class-definition>
Registers a new ResultType in fwk.xml:
<result-type name="twig" class="FwkTwig\TwigResultType">
<param name="twigService">twig</param>
</result-type>
Use the ResultType where you want:
<action name="Home" shortcut="MyApp\Controllers\Home:show">
<result name="success" type="twig">
<param name="file">home.twig</param>
</result>
</action>
- Issues on Github: https://github.com/nitronet/fwk-twig/issues
- Follow Fwk on Twitter: @phpfwk