VS Extension for JS Template Support
1 min read

VS Extension for JS Template Support

I am thinking of embarking on a journey that involves Backbone.js in my MVC 3 project. This would involve heavy use of templating. After thinking about it a bit and doing some Googling, I realized that there is no JS template extension for Visual Studio.

I realize that you could just name your template files ".html" and be done with it. However, I feel like that isn't "cool" enough.

Based on some preliminary research, it seems to me it would not be impossible to add support for common JS template syntax highlighting... and perhaps even Intellisense.

In fact, VS 11 will support jQuery Template syntax highlighting, but not only is jquery-tmpl obsolete, it is also not the only kind of templating system.

Why am I making this post? I am not sure. Part of me wants to attempt to make such an extension, probably starting out with a simple template syntax like Mustache (or Handlebars). I would be happy with an extension that was pretty much an HTML highlighter that also highlighted tokens (e.g. "{{", "}}", etc.) just like VS does for Razor. Bonus points awarded if it [somehow] does Intellisense. In my dream world, it would act very much like MVC Razor does right now, where you declare the "model" for the template and that is its context for Intellisense. To me, that seems reasonable for a no-logic template system like Mustache but may prove unwieldy once you allow for normal JS expressions like in jquery-tmpl. That kind of syntax may also not make sense in the first place considering you could pass in whatever you wanted into a template's context.

Enjoying these posts? Subscribe for more