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

Handlebars #321

Merged
merged 3 commits into from
Aug 27, 2013
Merged

Handlebars #321

merged 3 commits into from
Aug 27, 2013

Conversation

quisquous
Copy link
Contributor

This pull request adds support for indenting Handlebars expressions (http://handlebarsjs.com/) in the beautify-html js formatter. It adds a new option and indents Handlebars block expressions, e.g. {{#if}} and {{/if}} at the same level as html tags like

and
. Since there weren't any HTML formatting unit tests, I added some of those as well (although they're not very extensive) so that I could test Handlebars expressions too.

This change was useful for me, so I wanted to submit a pull request in case you were interested.

This adds a new 'indent_handlebars' option to the beautify-html
formatter.  When not turned on, anything inside handlebars {{ }} will be
treated as normal content as before.

When turned on, Handlebars block expressions (e.g. {{#anything}},
{{/anything}}, and special case {{else}}) are treated identically to
formatted HTML tags and indented properly.

Handlebars expressions inside of HTML tags get spaces on either side.

Handlebars expression in quotes are left unformatted.
@einars
Copy link
Contributor

einars commented Aug 27, 2013

Woo hoo, thank you, html tests, that's incredibly excellent!

You probably need to use "indent_handlebars" throughout the code, not "options.indent_handlebars" (which contains only the options passed by user).

Apart from that everything looks nice to me. I won't merge just yet, I'd like @bitwiseman and @evocateur to take their look as well.

@ghost ghost assigned bitwiseman and evocateur Aug 27, 2013
@bitwiseman
Copy link
Member

👍
Big win, thanks!

I'd like to see the html beautify tests in their own file, but that can happen later.

@evocateur
Copy link
Contributor

Looks great, thanks! This will definitely come in handy for me.

The indent_handlebars thing is mostly stylistic, since if unpassed, options.indent_handlebars is undefined, which is falsey enough for the comparisons. But yeah, consistency never hurts.

einars pushed a commit that referenced this pull request Aug 27, 2013
indent_handlebars support, HTML tests
@einars einars merged commit a045c45 into beautifier:master Aug 27, 2013
@quisquous quisquous deleted the handlebars branch August 28, 2013 00:25
@quisquous
Copy link
Contributor Author

Thanks! (And thanks for fixing up my misuse of options.indent_handlebars too.)

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

Successfully merging this pull request may close these issues.

4 participants