othree / html5.vim

HTML5 omnicomplete and syntax
http://www.vim.org/scripts/script.php?script_id=3236
934 stars 76 forks source link

Html indent doesn't work inside <script> tag #48

Closed gavruk closed 10 years ago

gavruk commented 10 years ago

Hi. Html indent doesn't work inside <script> tag. I use script tag for html template. I found that indent from this repo causes this issue. When I turned off html indent from this repo, indenting stated working as excepted.

vimindent

othree commented 10 years ago

This is designed behavior. The indent rule inside <script> should use indent code from javascript file type. I know the template usage. But I don't like it, I don't think this is a correct way to use <script>. So I will not fix this. But a patch is always welcome.

gavruk commented 10 years ago

What way of defining templates do you prefer? Is there are any other way? Hidden div doesn't work the same way

othree commented 10 years ago

HTML5 provides a new element called template. Which is invisible but will be parsed. Let it easy to clone and reuse.

And I am using handlebars but precomipled to JS functions. You can see the document for more information.

bartels commented 10 years ago

Just wanted to mention that AngularJS also uses the script tag for html templates with type="text/ng-template". I think this is technically valid according to the spec. Script tags can potentially be used for any scripting language by setting the type attribute (defaults to javascript if missing). The only posible solution I can think of is to check the type attribute to use different syntax. This doesn't necessarily sound very easy though.

I agree the template tag will be quite useful once it has more support.

othree commented 10 years ago

Hi, I trace the code and discovered:

text/html and text/template is allowed template type for <script Childrens of these two type of script tag will be indent. Others will not.

And I just add ng-template support.