Search code examples
symfonytemplatesnetbeanstwigcode-templates

NetBeans use custom code templates for a TWIG file


In my twig view files for a Symfony application I need to write a log {% trans %}Foo Bar Baz{% endtrans %} what is quite annoying.

Therefore I tried to make a template, where I just have to write trans press space and the magic is done.

I made a new Template in Twig File, Twig Block and Twig Variable but non of them worked. The Code I used was:

{% trans %}${TEXT}{% endtrans %}

Abbreviation is trans

Then I restarted NetBeans, but unfortunately nothing happens when I write trans in a .twig file.

What am I doing wrong? How do I have to do this?

Thanks (:


Solution

  • You should add your Code Template in the Twig Block language, not Twig File language.

    enter image description here

    You don't need to reboot netbeans.

    Then, type relatively quickly: {% trenter

    You'll come up with:

    enter image description here

    If you don't want to type {% at all, you can choose HTML language instead of Twig Block language (assuming your file name ends with .html.twig).