Ad

Is It Possible To Replace The Twig Language Format Of {% %} To: {%- -%}?

- 1 answer

{%- -%} is a whitespace delimiter in Shopify liquid. I am trying to edit the default emmet function in PhpStorm's twig language to instead output this rather than the default {% %}.

Also looking to change the default twig comment style from {# #} to {% comment %}{% endcomment %}

As this is specific to Liquid, I don't have access to editing the delimiters, such as is the case using something like Vue

Ad

Answer

Sadly, Twig support plugin does not allow customizing the lexer syntax yet.

https://youtrack.jetbrains.com/issue/WI-15739 -- watch this ticket (star/vote/comment) to get notified on any progress.


{% comment %}{% endcomment %} -- similar story (you cannot customize what symbols/tags are used for comments.

Proper Liquid templates support is tracked in the following ticket: https://youtrack.jetbrains.com/issue/RUBY-7210 -- star/vote/comment it to get notified on any progress. Hopefully devs can bring some updates in one of the next major versions (at very least there was some activity in this ticket in terms of expected Liquid support/functionality).


...default emmet function in PhpStorm's twig language...

Commenting functionality is not provided by Emmet by any means -- it's implemented by plugin specifically for this language (IDE has standard "Block Comment" and "Line Comment" actions and plugins for corresponding language just provides how the commenting should be handled.

If you want to use some emmet-like abbreviation that will expand into {% comment %}some text here{% endcomment %} or alike then you are welcome to create custom Live Template and use it even right now (e.g. as a "Surround with..." kind of template). You can create one at Settings (Preferences on macOS) | Editor | Live Templates.

https://www.jetbrains.com/help/phpstorm/using-live-templates.html

Ad
source: stackoverflow.com
Ad