Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FR] Add support for Block Shortcuts syntax #106

Closed
rungta opened this issue Dec 16, 2024 · 2 comments · Fixed by #107
Closed

[FR] Add support for Block Shortcuts syntax #106

rungta opened this issue Dec 16, 2024 · 2 comments · Fixed by #107
Labels
Bug Something isn't working Printer Logic related on how to print the output

Comments

@rungta
Copy link

rungta commented Dec 16, 2024

Twig allows a Block Shortcuts syntax:

{% block title %}
    {{ page_title|title }}
{% endblock %}

{% block title page_title|title %}

The plugin doesn't appear to recognise this at the moment.

[error] templates/_layouts/base.twig: Error: ERROR: Invalid Token
[error]   26 | #}
[error]   27 | {% block page_main %}
[error] > 28 |   <main class="{% block main_class '' %}">
[error]      |                ^^
[error]   29 |     {% block main %}{% endblock %}
[error]   30 |   </main>
[error]   31 | {% endblock %}
[error] 
[error] Expected stringEnd but found tag start "{%" instead.
[error]     at TokenStream.error (file:///…/node_modules/@zackad/prettier-plugin-twig/src/melody/melody-parser/TokenStream.js:129:24)
[error]     at TokenStream.expect (file:///…/node_modules/@zackad/prettier-plugin-twig/src/melody/melody-parser/TokenStream.js:103:14)
[error]     at Parser.matchAttributes (file:///…/node_modules/@zackad/prettier-plugin-twig/src/melody/melody-parser/Parser.js:413:28)
[error]     at Parser.matchElement (file:///…/node_modules/@zackad/prettier-plugin-twig/src/melody/melody-parser/Parser.js:337:14)
[error]     at Parser.parse (file:///…/node_modules/@zackad/prettier-plugin-twig/src/melody/melody-parser/Parser.js:211:32)
[error]     at Object.parse (file:///…/node_modules/@zackad/prettier-plugin-twig/src/melody/melody-extension-core/parser/block.js:42:24)
[error]     at Parser.matchTag (file:///…/node_modules/@zackad/prettier-plugin-twig/src/melody/melody-parser/Parser.js:498:31)
[error]     at Parser.parse (file:///…/node_modules/@zackad/prettier-plugin-twig/src/melody/melody-parser/Parser.js:177:32)
[error]     at Object.parse (file:///…/node_modules/@zackad/prettier-plugin-twig/src/parser.js:82:24)
[error]     at parse4 (file:///…/node_modules/prettier/index.mjs:20724:24)
@zackad zackad added Feature: Request Parser Logic related on how to parse twig template labels Dec 16, 2024
@zackad
Copy link
Owner

zackad commented Dec 16, 2024

The problem with your example is related to GH-61 that block expression in html attribute is not yet supported.

@zackad zackad added this to the Version 1.0 milestone Dec 16, 2024
@zackad zackad added Bug Something isn't working Printer Logic related on how to print the output and removed Feature: Request Parser Logic related on how to parse twig template labels Dec 17, 2024
@zackad
Copy link
Owner

zackad commented Dec 17, 2024

It turns out that block shortcut syntax has been supported. I fix printing string literal as block body value when using shortcut syntax.

@zackad zackad removed this from the Version 1.0 milestone Dec 17, 2024
@zackad zackad closed this as completed in fd5b244 Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Printer Logic related on how to print the output
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants
@rungta @zackad and others