Skip to content

Inside v-pre, a {{ }} expression shows {{ $citryPrepared.citryText0 }} instead of its value #329

Closed

Description

@JuroOravec

What happens

A Citry {{ }} expression inside an element with v-pre shows an
internal name on the page instead of the value or the authored text:

class Live(Component):
    template = """
        <main>
          <div v-pre>{{ 'a' }} and {{ name }}</div>
        </main>
    """

    def template_data(self, kwargs, slots):
        return {"name": "Ann"}

The page shows:

<main><div>{{ $citryPrepared.citryText0 }} and {{ $citryPrepared.citryText1 }}</div></main>

The same happens with or without js, because v-pre alone makes the
component a Vue component.

Why

Citry evaluates each {{ }} in Python and hands the value to Vue as data,
by writing {{ $citryPrepared.<key> }} into the Vue template. Vue skips
everything inside v-pre, so it never reads that data key and prints the
interpolation as text. The writer is in
packages/py/citry/citry/_vue/direct_capture.py (the data-key interpolation
around line 3699), which does not check whether the text sits inside
v-pre.

What it should do

Inside v-pre, Citry should write the value it already computed as
static text (a and Ann above), because Vue will not substitute it.
Alternatively, it could write the authored {{ ... }} as written, as Vue's
own v-pre does. The first option keeps a Citry {{ }} meaning the same
thing everywhere; the second follows Vue's meaning of v-pre. Either way,
the internal $citryPrepared name must not reach the page.

Found while checking which templates reach the Vue compiler for #313.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions