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

Disappearing newlines #857

Closed
difosfor opened this issue Sep 3, 2014 · 2 comments
Closed

Disappearing newlines #857

difosfor opened this issue Sep 3, 2014 · 2 comments

Comments

@difosfor
Copy link

difosfor commented Sep 3, 2014

I'm using the following technique to be able to declare partials inline. It works fine in v2.0.0-alpha.4, but in following versions, some of the newlines within helper blocks seem to be eaten up.

Am I doing something wrong or has an issue been introduced since then?

JavaScript:

Handlebars.registerHelper('partial', function(name, options) {
    Handlebars.registerPartial(name, options.fn);
});

Template (excerpt from: https://github.com/exmg/nbob/blob/master/res/em-api/playtotv-define.js.hbs):

        /**
{{~#partial "enum-values"}}{{#if enumValues}} Valid values: {{#join enumValues}}'{{.}}'{{/join}}{{/if}}{{/partial}}
{{~#partial "dto-params"}}
         * <ul>
{{~#.}}
         * <li><i>{ {{~type~}} }</i> <b>{{name}}</b>{{> enum-values}}{{#if pojo}}{{#with pojo.fieldsData}}{{> dto-params}}{{/with}}{{/if}}</li>
{{~/.}}
         * </ul>
{{~/partial}}
{{~#if responseVar.pojo}}
         * <b>Response data:</b>
{{~#with responseVar.pojo.fieldsData}}{{> dto-params}}{{/with}}
{{~/if}}

Output before:

        /**
         * <b>Response data:</b>
         * <ul>
         * <li><i>{number}</i> <b>status</b></li>
         * <li><i>{[VierErrorDTO]}</i> <b>errors</b>
         * <ul>
         * <li><i>{string}</i> <b>field</b></li>
         * <li><i>{string}</i> <b>message</b></li>
         * </ul></li>
         * <li><i>{string}</i> <b>uid</b></li>
         * </ul>

Output now:

        /**      * <b>Response data:</b>         * <ul>      * <li><i>{number}</i> <b>status</b></li>        * <li><i>{[VierErrorDTO]}</i> <b>errors</b>         * <ul>      * <li><i>{string}</i> <b>field</b></li>         * <li><i>{string}</i> <b>message</b></li>       * </ul></li>        * <li><i>{string}</i> <b>uid</b></li>       * </ul>
@kpdecker
Copy link
Collaborator

kpdecker commented Sep 4, 2014

beta1 introduced standalone statements, matching the mustache spec.
https://github.com/wycats/handlebars.js/blob/master/release-notes.md#v200-beta1---august-26th-2014

It looks like you uses of whitespace control is the reverse of the newlines that are left in place by the standalone logic. Do you still see funky rendering if you remove the explicit whitespace control that you have in that example? If so could you post a live example of the failure?

difosfor added a commit to exmg/nbob that referenced this issue Sep 5, 2014
…so back to Handlebars v2.0.0. Adapted playtotv-define.js.hbs template to work with standalone block whitespace removal. Removed em-define template since it was not really being used.
@difosfor
Copy link
Author

difosfor commented Sep 5, 2014

Thanks for the information!

I've adapted our template to work with Handlebars v2.0.0. Not sure if I did it the best way, or if everything works exactly the way that it should, but it's good enough for me :)

You can see my current template here:
https://github.com/exmg/nbob/blob/master/res/em-api/playtotv-define.js.hbs

And the diff in the commit referenced above.

Let me know if you would like anymore information.

@difosfor difosfor closed this as completed Sep 5, 2014
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

2 participants