mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
14486902fb
Currently the only way the extend SSTemplateParser is to define a class extension of it and then tell the injector component to use your new custom class. This new change allows a user to define new "open blocks" and "closed blocks" for SSTemplateParser to use without needing to recompile the real SSTemplateParser class. The following example shows how the functionality can be used to add a new <% minify %>…<% end_minify %> syntax to the template parser In a config.yml file, define the new minify closed block to call the static function "Minifier::minify" ``` Injector: SSTemplateParser: properties: closedBlocks: minify: "Minifier::minify" ``` Define a new class with the minify static method that returns the new template code when regenerating templates: ``` class Minifier { public static function minify(&$res) { return <<<PHP {$res['Template']['php']} \$val = zz\Html\HTMLMinify::minify(\$val, array('optimizationLevel' => zz\Html\HTMLMinify::OPTIMIZATION_ADVANCED)); PHP; } } ``` |
||
---|---|---|
.. | ||
themes/layouttest | ||
ContentNegotiatorTest.php | ||
SSViewerCacheBlockTest.php | ||
SSViewerTest.php | ||
ViewableDataTest.php |