0

Inspecting the mustache content in the below code with Developer: Inspect TM scopes

<p>name: {{ name }}</p>

I get text.html.basic, meaning there is no separate scope for changing the color of name inside the mustache tags. Is there any other way of changing the color of template props in Visual Studio Code?

1 Answer 1

2

If you don't find a better way with scopes, you could try the highlight extension.

And this setting seems to work:

"highlight.regexes": {

    "({{[/!^>#]*\\s*)([^}]+)(\\s*}})": [
         {},  // first match group "{{" gets no color, must be here
         {
            // "overviewRulerColor": "#ffcc00",
            "color": "#f00",
            // "fontWeight": "bold"
         },
         {} // third match group "}}" gets no color, does not need to be here
     ],
}

example of mustache syntax highlighting

Sign up to request clarification or add additional context in comments.

3 Comments

Edit : changed the regex so the desired capture of the template props is better and updated the image example.
i think youre missing a ) in the middle. the way you wrote it might as well take out the 3rd pattern. heres one for angular prop binding: "(\\s+\\[[\\w-]+\\]=\"[/!^>#]*)([^\"]+)"
You are right on your comments, a typo by me on the regex, and the last match group doesn't need to be included if you are doing nothing with it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.