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

Reindent functionality doesn't work inside templates #45

Open
hobbs opened this issue May 24, 2014 · 1 comment
Open

Reindent functionality doesn't work inside templates #45

hobbs opened this issue May 24, 2014 · 1 comment
Labels

Comments

@hobbs
Copy link

hobbs commented May 24, 2014

When using this plugin, or the standard html plugin, "reindent" functionality does not work inside script blocks. For example, in the example code below, using "reindent" on any of the opening or closing div tags does not move the tag out. Reindent on a large block of template markup just flattens it out to the same level as the script tag.

<html>
   <script type="text/x-handlebars" data-template-name="test">

   <div>
   <div>
   </div>
   </div>

   </script>
</html>

This is pretty critical for users for the sublemacspro (emacs keybindings), as tab is defaulted to reindent to match emacs functionality. If you have any thoughts on what the solution is I might be able to look into the fix, I just don't really know where to get started.

@daaain
Copy link
Owner

daaain commented May 26, 2014

Hey,

I'm not quite sure what's the root cause, but it's probably because of the fact that whatever is inside the script tags needs to be defined from scratch, as it is not part of the original DOM – that's why it's possible to have JavaScript in there which is obviously invalid HTML.

I think the best place to start would be understanding where the ST indentation engine is taking its information about structure, and then you can dig into what's defined for script tags in this particular package.

This is where the JavaScript bits are defined just for comparison:
https://github.com/daaain/Handlebars/blob/master/Handlebars.JSON-tmLanguage#L166

And this is the real deal where the HTML / Handlebars one is:
https://github.com/daaain/Handlebars/blob/master/Handlebars.JSON-tmLanguage#L576

Hope this helps!

@daaain daaain added the bug label Nov 30, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants