How to embed php in twig

后端 未结 3 538
旧时难觅i
旧时难觅i 2020-12-16 15:05

I have a do_shortcut and I need to embed it in a twig template. I tried by coping the code in a php file my-code.php:



        
3条回答
  •  有刺的猬
    2020-12-16 15:48

    About the include part, create a my_code.html.twig file at app/Resources/views/my_code.html.twig and copy-paste your code from my-code.php

    Then you can include that code anywhere like :

    {% include 'my_code.html.twig' %}
    

    EDIT: tested and working in symfony3

提交回复
热议问题