Skip to content

Add template directives support (%{if}, %{for}) in quoted strings#276

Merged
kkozik-amplify merged 4 commits intorelease/8.xfrom
template-directives-support
Mar 31, 2026
Merged

Add template directives support (%{if}, %{for}) in quoted strings#276
kkozik-amplify merged 4 commits intorelease/8.xfrom
template-directives-support

Conversation

@kkozik-amplify
Copy link
Copy Markdown
Collaborator

@kkozik-amplify kkozik-amplify commented Mar 11, 2026

Summary

  • Adds parsing support for HCL2 template directives (%{if}, %{else}, %{endif}, %{for}, %{endfor}) within quoted strings, including strip markers (~) and nested directives
  • Grammar uses flat directive rules assembled into nested structures by the transformer to avoid LALR conflicts
  • Full round-trip support: parse, serialize, deserialize, reconstruct all handle directives correctly

Caused by #247

Test plan

🤖 Generated with Claude Code

kkozik-amplify and others added 4 commits March 11, 2026 20:07
…t_specialized.py

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ass-level constant

DBLQUOTE was changed to match \" in addition to " but TEMPLATE_STRING
already handles escaped-quote strings inside directive expressions.
Reverted to the simpler literal match. Also moved _directive_rules from
a per-call local tuple to a class-level set in HCLReconstructor for
performance, and added a clarifying comment on the TEMPLATE_STRING regex.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add rules/directives.py entry and TemplateStringRule to rules/strings.py
entry to reflect new template directive support added in this branch.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@kkozik-amplify kkozik-amplify marked this pull request as ready for review March 31, 2026 14:48
@kkozik-amplify kkozik-amplify requested a review from a team as a code owner March 31, 2026 14:48
@kkozik-amplify kkozik-amplify merged commit e42f880 into release/8.x Mar 31, 2026
7 checks passed
@kkozik-amplify kkozik-amplify deleted the template-directives-support branch March 31, 2026 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants