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

js-beautify incompatible with handlebar syntax #453

Closed
ZhijieWang opened this issue Apr 26, 2014 · 6 comments
Closed

js-beautify incompatible with handlebar syntax #453

ZhijieWang opened this issue Apr 26, 2014 · 6 comments

Comments

@ZhijieWang
Copy link

js-beautify will break embedded html in handlebar syntax. I am not familiar with how js-beautify works. Is there anyway to add stuff like type="text/x-handlebars" to js-beautify as ignore?

Source

 <script id="some-template" type="text/x-handlebars-template"> <table>
  <thead> 
      <th>Name</th> 
      <th>Job Title</th> 
      <th>Twitter</th> 
  </thead> 
  <tbody> 
    {{#users}} 
    <tr> 
        <td>{{fullName person}}</td> 
        <td>{{jobTitle}}</td> 
        <td><a href="https://twitter.com/{{twitter}}">@{{twitter}}</a></td> 
    </tr> 
    {{/users}} 
</tbody> 
</table> 
</script>

After js-beautify

<script id="some-template" type="text/x-handlebars-template">
< table >
    < thead >
    < th > Name < /th> 
    <th>Job Title</th >
    < th > Twitter < /th> 
</thead >
    < tbody > {
        {#
            users
        }
} < tr >
    < td > {
        {
            fullName person
        }
} < /td> 
        <td>{{jobTitle}}</td >
    < td > < a href = "https://twitter.com/{{twitter}}" > @{
        {
            twitter
        }
} < /a></td >
    < /tr> 
    {{/users
}
} < /tbody> 
</script>
@bitwiseman
Copy link
Member

Are you running html-beautify or js-beautify on this?

@ZhijieWang
Copy link
Author

It was the http://jsbeautifier.org/. It has similar behavior in the jsbeautifier plugin for Bracket editor

@bitwiseman
Copy link
Member

Same problem as #385. To begin with we should ignore the contents of these tags, as a later enhancement we could try it actually format them.

@bitwiseman bitwiseman added bug and removed bug labels Apr 27, 2014
@tomByrer
Copy link

Bummer, this is needed for me since alot of dev work is with Handlebars syntax.
BTW, Handlebars/Mustache is used in alot of other frameworks, like EmberJS.

@bitwiseman
Copy link
Member

I totally agree it is worth fixing. Feel free to contribute! 😄

bitwiseman added a commit that referenced this issue May 21, 2014
Ignore html script and style tags with unexpdcted type attributes
Fixes #453
@wolkesson
Copy link

The fix would be needed for templates commonly used with bootstrap. For example:
<script id="pointsTmpl" type="text/html">

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

4 participants