Skip to content

Instantly share code, notes, and snippets.

@MichaelMackus
Created July 22, 2015 00:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MichaelMackus/774f837b2000196505bc to your computer and use it in GitHub Desktop.
Save MichaelMackus/774f837b2000196505bc to your computer and use it in GitHub Desktop.
Include raw twig template
<?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