Spacebars syntax highlighting?


#1

Hey, I was wondering if anyone knows of a way in sublime to highlight closing/ending spacebars logic as if they were tags, i.e. highlight the {{#if}} and closing {{/if}}, etc. Any ideas?


#2

I know this doesn’t answer your question, but… jade?

if Meteor.user
  h1 Welcome back
else
  h1.jumbotron Welcome new user!

sublime, atom, webstorm all provide decent levels of highlighting and significant space.
you never have to worry about closing brackets again… (replaced by significant space hell hehe :slight_smile: )

same code with {{#if}} in html

{{#if}} Meteor.user
  <h1> Welcome back </h1>
{{else}}
  <h1 class="jumbotron"> Welcome new user! </h1>
{{/if}}

Try it out for yourself


#3

Thanks! yeah, that’s a good idea. Def not going to go back and re-template past templates (even if there are tools for it), but that is definitely a good alternative for my future projects.


#4

Doesn’t even have to be future projects, they are fine side by side since jade just compiles into html, you can do this for your next template in your current project even and mquandalle:jade will happily precompile .jade files into html before meteor does it’s magic.

However, you ask for something quick (imo not available?) and going down this path will take a few days to get used to so up to you.


#5

I wasn’t sure if the feature is available or not. My templates aren’t such bowls of noodles that I need to dramatically simplify them per se; it was more that syntax highlighting in other contexts (closing brackets, tags, etc) is pretty common these days, so I thought maybe I was missing a feature that many other people are using.

this is tangental to my original question, but it seems like kinda bad practice to include multiple templating paradigms in a single project, even if it is possible. Maybe some people call that kind of thing “agile,” but I prefer to maintain certain operational conventions throughout a particular project so that other people besides myself can understand how it’s organized, if – hopefully – they eventually need to be scaled or collaborated.


#6

You could possibly look for handlebars syntax packages for sublime. Spacebars is forked off handlebars, so they share the same basic syntax.


#7

Thanks for the suggestion; I do have a handlebars syntax package. The problem is that it isn’t very useful, it just colors the brackets. probably going to shelve the issue, but thanks for the feedback!