Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggest using partials when stache auto-closes elements #713

Open
phillipskevin opened this issue Aug 8, 2019 · 0 comments
Open

Suggest using partials when stache auto-closes elements #713

phillipskevin opened this issue Aug 8, 2019 · 0 comments

Comments

@phillipskevin
Copy link
Contributor

From https://bitovi-community.slack.com/archives/CFC22NZ8A/p1565274636104700.

Stache will automatically close elements when trying to wrap an opening or closing tag (see "The following sections are not supported" in https://canjs.com/doc/can-stache.html#Magictags).

This means that if you do something like:

{{#if(vertical)}}
<div class='row'>
    <div class='col-3'>
{{/if}}

<p>some other content</p>

{{#if(vertical)}}
    </div>
</div>
{{/if}}

...stache will convert it to

<div class='row'>
    <div class='col-3'></div>
</div>

<p>some other content</p>

We give a warning for this:

unexpected closing tag expected

We should suggest using partials to handle this

{{<thestuff}}
    <p>some other content</p>
{{/thestuff}}

{{#if(vertical)}}
<div class='row'>
    <div class='col-3'>
        {{thestuff()}}
    </div>
</div>
{{else}}
{{thestuff()}}
{{/if}}

We should put a section in the docs for this and possible add a link to it from the warning (although it might be hard to determine when someone is doing this on purpose vs when it was a mistake).

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

No branches or pull requests

1 participant