Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Twig2011.12.04 Symfony   #5       @fivestr
ABOUT ME    @fivestr      PHP
TwigTwig       TIPS
Twig
Twig{{ foo }} => <?php echo $foo ?>{% if %}...{% endif %}
Twig{{ foo(arg) }} :{{ arg|foo }} :{% if arg is foo %} :{% foo %}{% endfoo %} :
TwigTwig_Extension
DemoExtensionsrc/Acme/DemoBundle/Twig/Extension/DemoExtension.phpcode
class DemoExtension extends Twig_Extension{   public function getFunctions()   {     return array(        code => new Twig...
getFunctions()                 getFunctions()     Twig
Twig_Function_Method(  $this, ‘getCode’, $options)public function getCode($template) {}{{ code(template) }} $this->getCode...
getFilters() / getTests()Twig_Filter_Method / Twig_Filter_Test
DI twig.extension
Twigエクステンションの作り方
Twigエクステンションの作り方
Upcoming SlideShare
Loading in …5
×

Twigエクステンションの作り方

9,625 views

Published on

Published in: Technology, Business
  • Be the first to comment

Twigエクステンションの作り方

  1. 1. Twig2011.12.04 Symfony #5 @fivestr
  2. 2. ABOUT ME @fivestr PHP
  3. 3. TwigTwig TIPS
  4. 4. Twig
  5. 5. Twig{{ foo }} => <?php echo $foo ?>{% if %}...{% endif %}
  6. 6. Twig{{ foo(arg) }} :{{ arg|foo }} :{% if arg is foo %} :{% foo %}{% endfoo %} :
  7. 7. TwigTwig_Extension
  8. 8. DemoExtensionsrc/Acme/DemoBundle/Twig/Extension/DemoExtension.phpcode
  9. 9. class DemoExtension extends Twig_Extension{ public function getFunctions() { return array( code => new Twig_Function_Method( $this, getCode, array(is_safe => array(html)) ), ); }}
  10. 10. getFunctions() getFunctions() Twig
  11. 11. Twig_Function_Method( $this, ‘getCode’, $options)public function getCode($template) {}{{ code(template) }} $this->getCode($template)
  12. 12. getFilters() / getTests()Twig_Filter_Method / Twig_Filter_Test
  13. 13. DI twig.extension

×