Search code examples
visual-studiovisual-studio-2013visual-studio-extensionscolor-coding

Color-code HTML in script templates


I've been using script tags for javascript templates like this. (This example uses Handlebars.js but many other templating engines follow the same convention.)

<script id="template" type="text/x-handlebars-template">
    <div>
        <span>{{ title }}</span>
    </div>
</script>

Visual Studio does not color code the HTML inside the <script> tag. Is there a way to do that?


Solution

  • If the type does not need to be explicitly text/x-handlebars-template, you can use text/html instead. Visual Studio understands this is meant to be interpreted as HTML and will thus color code it appropriately.