Created
July 22, 2015 00:34
-
-
Save MichaelMackus/774f837b2000196505bc to your computer and use it in GitHub Desktop.
Include raw twig template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class IncludeRawExtension extends \Twig_Extension | |
{ | |
public function getFunctions() | |
{ | |
return [ | |
new \Twig_SimpleFunction( | |
'includeRaw', | |
[$this, 'includeRaw'], | |
['needs_environment' => true, 'is_safe' => ['html']] | |
), | |
]; | |
} | |
public function includeRaw(\Twig_Environment $env, $template) | |
{ | |
return $env->getLoader()->getSource($template); | |
} | |
public function getName() | |
{ | |
return 'include_raw'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment