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

8,610 views

Published on

Published in: Technology, Business
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
8,610
On SlideShare
0
From Embeds
0
Number of Embeds
4,933
Actions
Shares
0
Downloads
9
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

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

×