Advertisement
Guest User

Untitled

a guest
Jul 10th, 2014
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.70 KB | None | 0 0
  1. <?php
  2. namespace Some\Bundle\Name\Twig;
  3.  
  4. class ScriptWrapExtension extends \Twig_Extension
  5. {
  6.  
  7.     public function getFunctions()
  8.     {
  9.         return array(
  10.           'script_start' => new \Twig_Function_Method($this, 'startScriptTag', array('is_safe' => array('html'))),
  11.           'script_end' => new \Twig_Function_Method($this, 'endScriptTag', array('is_safe' => array('html'))),
  12.         );
  13.     }
  14.  
  15.     public function startScriptTag($id)
  16.     {
  17.         return sprintf('<script type="text/html" id="%s">', $id);
  18.     }
  19.  
  20.     public function endScriptTag()
  21.     {
  22.         return sprintf('</script>');
  23.     }
  24.  
  25.     public function getName()
  26.     {
  27.         return 'script_wrap_extension';
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement