Perl5-IDEA icon indicating copy to clipboard operation
Perl5-IDEA copied to clipboard

Feature request: Support Template Toolkit Macros as anonymous BLOCK

Open JoedowJoedow opened this issue 2 years ago • 5 comments

Hey *, I would have have a feature request regarding following topic:

Template Toolkit has a feature regarding macros allowing anonymous block. (http://www.template-toolkit.org/docs/manual/Directives.html#section_MACRO) The syntax looks like

[% MACRO header BLOCK %] ...content... [% END %]

[% header %]

When Pycharm parses the .tt2 file it detects an error (TT2: TT2_IDENTIFIER expected, got '%]'

I would assume that the TemplateToolkit.bnf file needs do consider for macro_directive the optional "BLOCK" directive

Thanks a lot for your work on this plugin

PS.: seen on latest PyCharm 2023.1.3, Win 10

JoedowJoedow avatar Jul 06 '23 08:07 JoedowJoedow

Please, provide a full snippet and a screenshot, because it works for me: image

hurricup avatar Jul 08 '23 03:07 hurricup

macro_header_with_block

JoedowJoedow avatar Jul 13 '23 15:07 JoedowJoedow

Hey hurricup, thanks for your quick reply. I pasted a screenshot taken from PyCharm and at least there I get the error message as you see on the upper right corner. It's also independent if I use parameters or not. Greets Cristof

JoedowJoedow avatar Jul 13 '23 15:07 JoedowJoedow

Please, provide a snippet, not a screenshot.

hurricup avatar Jul 14 '23 02:07 hurricup

[% MACRO print_message BLOCK %] [% RAWPERL %] print($context->stash->{'message'} . "\n"); [% END %] [% END %]

[% MACRO print_message(message) BLOCK %] [% RAWPERL %] print($context->stash->{'message'} . "\n"); [% END %] [% END %]

In the screenshot you see the red welled line and when you hoover over it it messages: TT2: TT2_IDENTIFIER expected, got '%]'

Hope that clarifies it. Greets Cristof

JoedowJoedow avatar Jul 14 '23 07:07 JoedowJoedow