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

Is it possible to make mustache statements a little cleaner? #1193

Closed
donnyv opened this issue Sep 10, 2014 · 6 comments
Closed

Is it possible to make mustache statements a little cleaner? #1193

donnyv opened this issue Sep 10, 2014 · 6 comments

Comments

@donnyv
Copy link

donnyv commented Sep 10, 2014

Is it possible not to have to close every mustache statement with its opening statement?
For example instead of this

    <div style="text-align:center;">
        {{#if feature_count > 0 && is_processing == false }}
        <span><b>{{feature_count}}</b> features found</span>
        {{/if}}
        {{#if is_processing}}
        <img src="Content/imgs/red-ajax-loader.gif" style="margin-right:10px;" />
        {{/if}}
        {{#if status_msg && feature_count > 0}}
        <br/>
        {{/if}}
        {{#if status_msg}}
        <span style="{{ is_processing ? "" : "color:#bf0000" }};">{{status_msg}}</span>
         {{/if}}
     </div>

....have this

    <div style="text-align:center;">
        {{#if feature_count > 0 && is_processing == false }}
        <span><b>{{feature_count}}</b> features found</span>
        {{/}}
        {{#if is_processing}}
        <img src="Content/imgs/red-ajax-loader.gif" style="margin-right:10px;" />
        {{/}}
        {{#if status_msg && feature_count > 0}}
        <br/>
        {{/}}
        {{#if status_msg}}
        <span style="{{ is_processing ? "" : "color:#bf0000" }};">{{status_msg}}</span>
         {{/}}
     </div>

Its a small change but it makes it easier to read.

@evs-chris
Copy link
Contributor

You can do that if you skip the section names:

<div style="text-align:center;">
        {{#(feature_count > 0 && is_processing == false) }}
        <span><b>{{feature_count}}</b> features found</span>
        {{/}}
        {{#is_processing}}
        <img src="Content/imgs/red-ajax-loader.gif" style="margin-right:10px;" />
        {{/}}
        {{#(status_msg && feature_count > 0)}}
        <br/>
        {{/}}
        {{#status_msg}}
        <span style="{{ is_processing ? "" : "color:#bf0000" }};">{{status_msg}}</span>
         {{/}}
     </div>

@donnyv
Copy link
Author

donnyv commented Sep 10, 2014

Thats how I originally had it. But I like having the extra statements around it "if, each, etc".
It tells me if the section is a if statement or loop.

@evs-chris
Copy link
Contributor

Looking back into the if, etc support issues, it would seem that they are not part of mustache, but part of handlebars. It looks like handlebars requires the closing section to have the correct string behind it. See #770 (comment)

@MartinKolarik
Copy link
Member

Looking back into the if, etc support issues, it would seem that they are not part of mustache, but part of handlebars. It looks like handlebars requires the closing section to have the correct string behind it.

Exactly. And I don't think we should change it.

@donnyv
Copy link
Author

donnyv commented Sep 11, 2014

Its not a big deal. I just like to remove as much as possible when coding.

@martypdx
Copy link
Contributor

@donnyv let's keep it as-is

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

No branches or pull requests

4 participants