daaain / Handlebars

Fullest Handlebars.js templating support for Sublime Text 2 / 3. Also drives syntax colouring on Github and in Visual Studio Code. Install from: https://packagecontrol.io/packages/Handlebars.
MIT License
301 stars 48 forks source link

Emmet doesn't work within <script> template #27

Closed arechsteiner closed 8 years ago

arechsteiner commented 10 years ago

I have the following template within a server side handlebars template, index.hbs:

<script type="text/x-handlebars-template" id="question-form-template">
  <p>\{{ question }}</p>
</script>

While syntax highlighting works, Emmet doesn't. I'm not sure how to make it work. I've tried this solution on handlebars.tmlanguage:

http://www.sublimetext.com/forum/viewtopic.php?f=2&t=4057

To no avail, unfortunately.

Note: I'm using Handlebars both on the server (via express-hbs) as well as on the front end with Backbone, hence a Handlebars template within a Handlebars template :)

daaain commented 10 years ago

Hey,

Sorry for taking ages to reply :(

Does this work if you don't use the Handlebars package?

I think this might need to be changed in the core HTML package as Handlebars is extending that one.

It's quite limited what you can do on top of existing language definitions, so the other alternative is having to reimplement / paste wholesale the HTML(5) package contents into Handlebars in order to be able to make these tweaks, which is of course a maintenance nightmare so I'm a bit reluctant to go more and more down that route.

That said, it might also be an extra twist that you're nesting this inside a Handlebars template, I'm not 100% sure if that's handled by ST or it would be necessary to duplicate and nest the language definition into itself for this to work.

arechsteiner commented 10 years ago

Hi

Yes it works in HTML after I apply the fix. Here is my HTML.tmLanguage, line 286 and 287:

<!-- <string>(?:^\s+)?(&lt;)((?i:script))\b(?![^&gt;]*/&gt;)</string> -->
<string>(?:^\s+)?(&lt;)((?i:script))\b(?!([^&gt;]*text/x-handlebars-template[^&gt;]*|[^&gt;]*/&gt;))</string>

(Note: the commented one is the original line, the other one is the fix)

I also added this in Handlebars.tmLanguage, line 506/507.

The result is that it works in .html files, but not in .hbs files.

daaain commented 8 years ago

I just had a look, and it seems Emmet is working within script tags, at least a text selection one I tried does.

Can you please confirm @arechsteiner if it works for you now? If not, can you please let me know what Emmet functionality you're trying to use?

arechsteiner commented 8 years ago

@daaain I've since switched to Vim, so I'm not using this plug-in any more.

daaain commented 8 years ago

Oh well, in that case I'm definitely closing this issue down :)

Thanks for the heads up!