Skip to content

fix: make citry check's template match the render for a v-pre element Citry compiles - #526

Merged
JuroOravec merged 3 commits into
mainfrom
fix/v-pre-check-template
Oct 28, 2026
Merged

JuroOravec merged 3 commits into
mainfrom
fix/v-pre-check-template

Conversation

@JuroOravec

Copy link
Copy Markdown
Member

Stacked on #525 (fix/v-pre-plain). Review #525 first; this PR's diff is the one commit on top. It will be retargeted to main once #525 merges.

What this fixes

citry check compiles a Vue template that should match what a render hands to Vue (_vue/static_template.py). For a v-pre element Vue reads as written, they match since #514. When Citry compiles a v-pre element itself because it holds Citry values, such as <textarea v-pre>{{ title }}</textarea>, they differed (#517):

  • The render drops v-pre, keeps the v-citry-vue-owned marker, and writes the contents as one block of HTML that Vue inserts without compiling. For textarea, title, script and style, and for placements that cannot hold such a block (tables and their rows or sections, SVG, MathML), it compiles the contents as usual.
  • The check template kept v-pre and dropped the marker.

Changes

  • static_template.py makes the render's decision from the template's nodes (_v_pre_left_to_vue, _authored_opening, _authored_nodes_only), then writes what the render writes: no v-pre, the marker, and the opaque block or the usual compile. It reuses the render's _TEXT_ONLY_TAGS and _html_block_placement_problem.
  • The render and the check cannot share one function: the render reads the parts it rendered, the check only the template's nodes. Their docstrings point at each other, and the parity tests keep them in step (direct_capture.py gets a docstring note only).
  • A <c-slot> fallback writer now starts from the outer open elements, so a v-pre element in a fallback inside <svg> matches the render.
  • docs_site/content/ide/template-linting.md: the page said the compile rule checks nesting inside every v-pre; it now says when it does not.

Cases

About 45 templates were compared between the check and the render; 32 differed before this change, and all match now. They include textarea, title, style and script with {{ }}; c-value on a textarea; a c- attribute or #c-key on the element or a child; <c-if>, <c-for>, <c-provide>, <c-cache>, and a simple component inside; nested v-pre; <pre> with a leading newline; <c-raw>; #c-ignore with v-pre; table, tbody/td, and SVG placements; and v-pre inside a fill, inside <c-if>, or in a slot fallback inside <svg>.

Ten new parity tests in test_vue_static_template.py, observed and then locked; all fail on the base revision. The #514 cases still pass.

Still different, and written down in the module docstring because the check cannot know them from the template:

  • a transparent component inside a v-pre element that renders only plain markup, which the render then leaves to Vue;
  • a c- attribute whose value is None or False, which writes no attribute;
  • root markers such as the one css_data() needs, which the check never models.

Tests

Run with this commit on top of #525: the citry and Citry UI suites pass (13,707). The one failing test, a Citry UI type-check test, fails only in my local environment (ty 0.0.90 there; main needs 0.0.91). ruff and mypy (also --platform linux) are clean. Two independent reviews ran, each with a separate prose pass.

No CHANGELOG entry: the Vue compile rule and static_template.py are not in a released version yet.

Fixes #517.

🤖 Generated with Claude Code

JuroOravec and others added 2 commits October 28, 2026 22:20
Inside v-pre, Vue reads directives as plain attributes and tags as plain
elements. Citry's template parser still ran its Vue-only checks there, so
v-once, <transition>, or @click.bogus inside v-pre failed to load, and
vize compiled <slot>, <component is>, <teleport>, <keep-alive>, and
<transition> inside v-pre as live Vue.

- The template parser skips the Vue-only checks for an HTML element that
  carries v-pre or sits inside one, and rejects v-pre written with an
  argument or modifiers. Citry tags keep their checks, and Vue slot syntax
  on a component's direct child keeps its check inside v-pre.
- vize's S2 lane (patched, now 0.420.0+citry.7) keeps those tags plain
  inside v-pre and on the element that opens it, and drops `is` from a
  plain <component>, matching @vue/compiler-dom 3.5.42.
- Citry's Vue compiler refuses (V_PRE_NEEDS_S2_LANE) a v-pre template
  that only vize's fallback lane would compile, since that lane still
  reads those tags as live (#519), and its metadata walk no longer
  reports a <slot> or fill under v-pre as an outlet.
- v-once and v-memo inside v-pre render as plain attributes; elsewhere
  they are still refused.
- When v-pre sits on a Vue-typed tag whose contents hold Citry values,
  rendering fails with advice to put v-pre on an element around it.

Fixes #515.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… Citry compiles

When a v-pre element holds Citry values, a render drops v-pre, writes the
contents as one block of HTML that Vue inserts without compiling (or, for
textarea, title, script, style, and placements that cannot hold such a
block, compiles them as usual), and keeps the v-citry-vue-owned marker.
The check template kept v-pre and dropped the marker. It now makes the
same decision from the template's nodes and writes the same template;
the two decisions point at each other and parity tests keep them in step.
A <c-slot> fallback writer now starts from the outer open elements, so a
v-pre element in a fallback inside <svg> matches too.

Fixes #517.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Base automatically changed from fix/v-pre-plain to main October 28, 2026 21:35
@JuroOravec
JuroOravec merged commit 18134cf into main Oct 28, 2026
0 of 9 checks passed
@JuroOravec
JuroOravec deleted the fix/v-pre-check-template branch October 28, 2026 21:37
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.

citry check's template differs from the render for a v-pre element that holds Citry values

1 participant