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

AngularJS inline templates are being corrupted! #385

Closed
royts opened this issue Jan 14, 2014 · 5 comments
Closed

AngularJS inline templates are being corrupted! #385

royts opened this issue Jan 14, 2014 · 5 comments

Comments

@royts
Copy link

royts commented Jan 14, 2014

Thanks for this wonderful tool.

Here is the syntax of angular inline template:

<script type="text/ng-template" id="defaultTableHeaderTemplate">
  <div ng-controller="control1">
    <div ng-model="model1"></div>
  </div>
</script>

js-beautify doesn't like the hyphen in special angular attributes (and HTML tags in general) and I'm end up with:

<script type="text/ng-template" id="defaultTableHeaderTemplate">
  < div ng - controller = "control1" > < div ng - model = "model1" > <
    /div>
  </div >
</script>

This is a real problem. Any way to solve it?

@einars
Copy link
Contributor

einars commented Jan 14, 2014

The actual problem is that the html-beautifier doesn't care for the type attribute of the script tag: it sees a script, it treats it as a beautifiable chunk.

@alvarolm
Copy link

there isnt any way to tell js-beautify to just indent the content between the tags

<script type="text/ng-template" ...> 

and

</script>

?

@bitwiseman
Copy link
Member

Yes, that is possible. As @einars said, we don't check the type attribute right now.
The code path we'd need to change is near https://github.com/einars/js-beautify/blob/master/js/lib/beautify-html.js#L783 - we'd add something to make sure we only indent the content of script/style tags that are marked with the expected js/css types.

nightspirit referenced this issue in brackets-beautify/brackets-beautify Mar 14, 2014
@nightspirit
Copy link

That would be great if you can beautify those templates as HTML.

@bitwiseman
Copy link
Member

I think this is fixed in v1.5.2. Please review and comment if I'm wrong.

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

5 participants