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

unexpectd indent #816

Open
peachest opened this issue Feb 28, 2023 · 0 comments
Open

unexpectd indent #816

peachest opened this issue Feb 28, 2023 · 0 comments

Comments

@peachest
Copy link

test.mustache:

env: {
    {{#env}}{{#es6}}es6: true,
    {{/es6}}{{#jasmine}}jasmine: true,
    {{/jasmine}}{{/env}}
}

I store this file locally and use const template = fs.readFileSync().toString() to get the template text.

view:

const view = {
    env: {
        es6: true,
    }
}
// or
const view = {
    env: {
        es6: true,
        jasmine: true,
    }
}

When I execute mustache.render(template, view), I got the following output:

env: {
    es6: true,
    }

The indent of the end bracket is unexpectd.

expect:

env: {
    es6: true,    
}
// or
env: {
    es6: true,
    jasmine: true,
}

However, if I insert a linebreak after the tag in test.mustache, just like the following:

env: {
    {{#env}}{{#es6}}es6: true,
    {{/es6}}{{#jasmine}}jasmine: true,
    {{/jasmine}}{{/env}}
    
}

then I got:

env: {
    es6: true,
    
}

Now the indent of the bracket is right, but I got an extra empty line which is also unexpected.

I wonder why I got these result ? Is the way I read the .mustaache file wrong ?

Also may anybody provide a beautiful solution for this problem.

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

2 participants
@peachest and others