Skip to content

docs: document {{#if}} / {{#else}} / {{#endif}} template syntax in instructions files#29637

Merged
pelikhan merged 2 commits intomainfrom
copilot/review-instructions-files-ensure-syntax-documentat
May 1, 2026
Merged

docs: document {{#if}} / {{#else}} / {{#endif}} template syntax in instructions files#29637
pelikhan merged 2 commits intomainfrom
copilot/review-instructions-files-ensure-syntax-documentat

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 1, 2026

Summary

Ensures the {{#if}} template conditional syntax is clearly documented for the model, prompted by the additions in #29620 which introduced {{#else}} / {{#endif}} support.

Changes

github-agentic-workflows.md

Added a new "Prompt Template Conditionals ({{#if}})" section (after the "GitHub Context Expression Interpolation" section) covering:

  • Full syntax ({{#if}} / {{#else}} / {{#endif}})
  • Clarification that {{#endif}} is the primary/preferred closing tag and {{/if}} is permanently supported as an alternate
  • Supported condition forms (bare value, equality ==, inequality !=, strict equality ===/!==)
  • Two usage examples (with and without {{#else}})
  • Integration note pointing to experiments.md
  • Key notes: fenced code blocks are preserved, nested conditionals are not supported, tags are stripped before the agent sees the prompt

experiments.md

Updated all code examples to use:

  • {{#else}} instead of {{else}}
  • {{#endif}} instead of {{/if}} (the primary closing form)

Copilot AI and others added 2 commits May 1, 2026 21:48
@pelikhan pelikhan marked this pull request as ready for review May 1, 2026 22:00
Copilot AI review requested due to automatic review settings May 1, 2026 22:00
@pelikhan pelikhan merged commit e262a28 into main May 1, 2026
3 checks passed
@pelikhan pelikhan deleted the copilot/review-instructions-files-ensure-syntax-documentat branch May 1, 2026 22:00
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Documents the workflow prompt templating conditionals ({{#if}} / {{#else}} / {{#endif}}) and updates experiment documentation/examples to match the newer tag forms.

Changes:

  • Added a “Prompt Template Conditionals ({{#if}})" section to clarify conditional syntax, supported operators, and usage notes.
  • Updated .github/aw/experiments.md examples to use {{#else}} and {{#endif}}.
  • Updated the experiment spec JSON shape in the daily attribution workflow lock file.
Show a summary per file
File Description
.github/workflows/daily-community-attribution.lock.yml Updates GH_AW_EXPERIMENT_SPEC to the newer { variants: [...] } schema form.
.github/aw/github-agentic-workflows.md Adds documentation for conditional template syntax and behavior.
.github/aw/experiments.md Refreshes examples to the new {{#else}} / {{#endif}} tag forms.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comments suppressed due to low confidence (1)

.github/aw/github-agentic-workflows.md:2197

  • The “Notes” bullets conflict: you state tags in fenced code blocks are preserved verbatim, but then say template tags are not visible to the agent and are stripped. Also, nested conditionals are not reliably treated as literal text by the current regex-based renderer (behavior is effectively undefined). Suggest clarifying that tags are stripped only for supported, well-formed conditionals outside fenced code blocks, and that nested conditionals are unsupported/undefined (may render incorrectly or leak tags).
- **Fenced code blocks are preserved** — `{{#if}}` tags inside `` ``` `` blocks are never processed; they appear verbatim in the output.
- **Nested conditionals are not supported** — do not place `{{#if}}` inside another `{{#if}}` block; the inner tags will be treated as literal text and appear verbatim in the agent prompt.
- **Template tags are not visible to the agent** — all `{{#if}}` / `{{#else}}` / `{{#endif}}` tags are stripped from the prompt before the agent runs.
  • Files reviewed: 3/3 changed files
  • Comments generated: 2


| Form | Example | Truthy when |
|---|---|---|
| Bare value | `{{#if experiments.flag }}` | value is non-empty and not `"false"` |
Copy link

Copilot AI May 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The truthiness semantics for the “Bare value” condition look incomplete/inaccurate vs the implementation in actions/setup/js/is_truthy.cjs: it treats (case-insensitive) "", "false", "no", "0", "null", and "undefined" as falsy. The docs currently only call out empty + "false", which could lead authors to accidentally keep blocks for values like 0/no/null.

Suggested change
| Bare value | `{{#if experiments.flag }}` | value is non-empty and not `"false"` |
| Bare value | `{{#if experiments.flag }}` | value is not empty and is not any of `"false"`, `"no"`, `"0"`, `"null"`, or `"undefined"` (case-insensitive) |

Copilot uses AI. Check for mistakes.

## Prompt Template Conditionals (`{{#if}}`)

The workflow markdown body supports a lightweight template language for conditional blocks. Template tags are resolved **at runtime, before the agent receives the prompt** — the agent always sees the final resolved text.
Copy link

Copilot AI May 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section says template tags are resolved at runtime and the agent “always sees the final resolved text”. In practice, renderMarkdownTemplate only removes tags for well‑formed supported patterns; malformed blocks (e.g., missing closing tag) are left unchanged, and tags inside fenced code blocks are intentionally preserved. Consider softening the wording to avoid implying tags can never reach the agent.

This issue also appears on line 2195 of the same file.

Suggested change
The workflow markdown body supports a lightweight template language for conditional blocks. Template tags are resolved **at runtime, before the agent receives the prompt** the agent always sees the final resolved text.
The workflow markdown body supports a lightweight template language for conditional blocks. Supported template tags are resolved **at runtime, before the agent receives the prompt**, so the agent typically sees the rendered result; malformed tags or tags in preserved contexts may remain unchanged.

Copilot uses AI. Check for mistakes.
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.

3 participants