mjbvz / vscode-lit-html

Adds syntax highlighting for html inside of JavaScript and TypeScript tagged template strings
https://marketplace.visualstudio.com/items?itemName=bierner.lit-html
MIT License
318 stars 75 forks source link

able to customize template tag aside from 'html' (TemplateResult) #64

Open aelbore opened 5 years ago

aelbore commented 5 years ago

i create my own template result like

const template = (strings, ...values) => 
  new TemplateResult(strings, values, 'html', defaultTemplateProcessor)

i want to have syntax coloring.

const myTemplate = template `<h1>Hello World</h1>`
krle997 commented 5 years ago

This is problem for me too. My function name is also called template, but when I use

template<div class=""></div>

I only get intellisense, the whole string is colored green. Could you make the settings.json when we edit and add a new tag that it loads both html colors AND intellisense... Thanks!

rzahniser commented 5 years ago

As a temporary workaround, you can edit the extension files directly. Go to .vscode/extensions/bierner.lit-html-1.11.0/syntaxes/lit-html.json, and change this line:

"begin": "(?x)(\\b(?:\\w+\\.)*(?:html|raw)\\s*)(`)",

...to contain "template" or whatever other tag(s) you want to use. You'll need to restart VSCode to see the change.

martypdx commented 5 years ago

This config features appears to be broken. Adding the following to settings does not work:

 "lit-html.tags": [
        "html",
        "raw",
        "banana"
    ],
const template = banana`<span>no syntax highlighting :(</span>`

I can confirm the monkey-patch work around suggested by @rzahniser works. For those wondering, the path referred to is in your home directory.

ivanjeremic commented 1 year ago

This config features appears to be broken. Adding the following to settings does not work:

 "lit-html.tags": [
        "html",
        "raw",
        "banana"
    ],
const template = banana`<span>no syntax highlighting :(</span>`

I can confirm the monkey-patch work around suggested by @rzahniser works. For those wondering, the path referred to is in your home directory.

Why is this config still broken? Is the only way of making this work to fork the repo and do what @rzahniser sugguested?

I need syntax highlighting for

component`<div>Hey</div>`