-
Notifications
You must be signed in to change notification settings - Fork 107
js-beautify support for mustache and handlebars #170
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
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
@googlebot I signed it! |
CI is still failing, but I see in the tests for js-beautify are fine this time. The problem is with another formatter I think. |
autoload/codefmt/jsbeautify.vim
Outdated
return &filetype is# 'css' || &filetype is# 'html' || &filetype is# 'json' || | ||
return &filetype is# 'css' || &filetype =~ 'html.*' || &filetype is# 'json' || | ||
\ &filetype is# 'javascript' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This loose matching includes some patterns you might not have intended. Consider changing it to something like
&filetype is# 'html' || &filetype =~# '\mhtml\.'
Without the #
the behavior subtly depends on the 'ignorecase'
setting, and the loose .*
will match on characters that aren't a literal dot, such as some weird htmlos
filetype vim has that doesn't seem to be anything like actual HTML syntax.
autoload/codefmt/jsbeautify.vim
Outdated
elseif &filetype != "" | ||
let l:cmd = l:cmd + ['--type', &filetype] | ||
elseif &filetype |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this line here by accident? It's "harmless" but has no effect.
The `mustache/vim-mustache-handlebars` plugin sets the filetype to either `html.handlebars` or `html.mustache`. Even though js-beautify supports formatting for these files, the `--type` parameter must be `html`. This commit sets the `--type` parameter to `html` when the filetype either is `html` or matches the regex `\mhtml\.`.
I addressed the two changes you requested and also squashed the commits to make history nicer. Let me know if this works. |
Thanks, merging! |
The mustache/vim-mustache-handlebars plugin sets the filetype to either
html.handlebars or html.mustache. Even though js-beautify supports
formatting for these files, the
--type
parameter must behtml
.This commit sets the
--type
parameter tohtml
when the filetypematches the regex
html\..*
.