Skip to content

feat(vue): pass Vue data to a fill with <c-slot :row> and <c-fill v-slot> - #445

Merged
JuroOravec merged 1 commit into
mainfrom
feat/vue-slot-props
Oct 27, 2026
Merged

JuroOravec merged 1 commit into
mainfrom
feat/vue-slot-props

Conversation

@JuroOravec

Copy link
Copy Markdown
Member

What this does

A component can now pass browser data to the content a caller puts in its slot (a Vue scoped slot):

{# Inside List #}
<li v-for="row in visible" :key="row.id">
  <c-slot name="item" :row="row" />
</li>

{# The caller #}
<c-List>
  <c-fill name="item" v-slot="{ row }">
    <span v-text="row.title"></span>
  </c-fill>
</c-List>

Citry writes :row on the Vue <slot> element it generates for the slot in List's compiled template, and the v-slot pattern on the fill's slot function in the caller's template, after the names extensions add (for i18n, $citryI18nBinding, $i18n). Python slot data (c-item, data="...") keeps working beside it.

This is the first of two PRs for #168; the Rust server renderer change follows. Until it lands, on a page that uses Vue the server leaves a v-slot fill's place empty, and Vue builds the contents of the element around the component tag in the browser. With no element around the tag, Vue builds the whole page.

Rules

  • Parser (citry_template_parser, no grammar, AST or compiler-output change). It accepts :row and v-bind:row (v-bind in lowercase) with a fixed name and no modifiers, and one object pattern or one name in v-slot. It rejects:
    • every other form, each with a hint;
    • the prop names name and key, and names starting with c-, $, _ or citry;
    • clashes between two props, between a prop and Python slot data, and between a v-slot name and the fill's data or fallback;
    • $, _ or citry names in v-slot, and {{ ... }} in a prop or a pattern;
    • in a pattern: comments, text around the parameter, &, computed keys, non-literal defaults, and a top-level key.
  • Render time:
    • Python data cannot add a prop or a pattern through c-bind, and c-bind names that clash with them fail.
    • A component that copies its slot content in place (<c-provide>, <c-cache>, <c-element>, transparent = True) fails on a scoped fill passed to it, and on : props on its own <c-slot>. So does a Python Slot that would call a scoped fill at an outlet with props.
    • A fill holding Citry components fails at render when the <c-slot> it reaches, directly or through a middle component, sits inside a Vue v-for. That page used to fail in the browser once the list held more than one item.
  • Other paths. A fill passed on by a middle component (for example CTabs) forwards the whole props object. The key Vue passes for Citry's v-if around each slot is bound to a reserved name, so a props object or ...rest never sees it.
  • Cache. Cached renders store the props and pattern (the plan proposed reading them again from the stored source). Reading an entry back parses them with the template parser, so a changed entry is a cache miss.
  • citry check. It compiles props and patterns, and reports a scoped fill passed to a component that copies it in place.

Left for later, on purpose

  • The Rust server renderer change: server HTML for fills with v-slot.
  • citry check does not flag <c-slot :row> inside a component that is itself transparent = True. Every render of it fails with a clear error.
  • A v-slot name equal to an enclosing <c-for> variable is not flagged: Vue expressions in the fill read the slot prop, and Python expressions read the loop variable.
  • An older bug, unchanged here: a fill's fallback handle compiles the receiving component's fallback into the caller's template, so Vue names in that fallback read the caller's data (often undefined).
  • No browser test on an i18n page yet. Unit tests cover the merged i18n pattern.
  • The plan's error for slot props on a page without Vue was dropped. On such a page, :row and v-slot alone reach nothing, and any fill that reads a v-slot name uses Vue syntax, which turns Vue on.

Tests

  • Rust: parser tests for every accepted and rejected form.
  • Python: test_vue_slot_props.py covers outlets, patterns with and without context names, forwarding, cache round trips and tampered entries, the Events producer, each refusal above, and the v-for check including the middle-component case. There are also new citry check tests in test_vue_compile_lint.py.
  • e2e: test_vue_slot_props_e2e.py.

Part of #168.

🤖 Generated with Claude Code

…lot>

A component can now pass browser data to the content a caller puts in its
slot. <c-slot name="item" :row="row" /> writes the prop on the Vue <slot>
Citry generates for the slot, and <c-fill name="item" v-slot="{ row }">
reads it in the fill's slot function, after the names extensions add.
Python slot data keeps working beside it.

The parser accepts :row and v-bind:row with a fixed name, and one object
pattern or one name in v-slot. It rejects every other form with a hint,
name clashes, the slot's own name and key, c- and reserved names, and, in
a pattern, comments, text around the parameter, '&', computed keys,
non-literal defaults and a top-level key, all of which Citry could not
merge or Vue would read from the wrong scope.

At render, Python data cannot add either form through c-bind, and c-bind
names that clash with them fail. A component that copies its slot content
in place refuses a scoped fill, as does a Python Slot that would call one
at an outlet with props. A fill holding Citry components now fails at
render when the <c-slot> it reaches, directly or through a middle
component, sits inside a Vue v-for; the page used to fail in the browser.
Vue's key for Citry's v-if is bound away from props objects and rests.
Cached renders store the props and pattern and parse them on read, and
citry check compiles them and reports scoped fills copied in place.

Part of #168.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@JuroOravec
JuroOravec added this pull request to stack #454 October 27, 2026 16:35
@JuroOravec
JuroOravec merged commit 7347b21 into main Oct 27, 2026
13 of 34 checks passed
@JuroOravec
JuroOravec deleted the feat/vue-slot-props branch October 27, 2026 16:40
JuroOravec added a commit that referenced this pull request Nov 1, 2026
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.

1 participant