Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tagged template literals #3026

Closed
ForbesLindesay opened this issue Jan 10, 2015 · 3 comments
Closed

Tagged template literals #3026

ForbesLindesay opened this issue Jan 10, 2015 · 3 comments

Comments

@ForbesLindesay
Copy link
Contributor

I'd like an easy way to contribute plugins for the JavaScript mode to add special overlays for specific tagged template literals. Currently I have this code which attempts to add the overlay via some horrible hacks so that something like:

var template = jade`
h1 The Jade Language
p Jade is an awesome language
`;

gets syntax highlighted as JavaScript with a section of jade in it.

@marijnh
Copy link
Member

marijnh commented Jan 12, 2015

You definitely don't want to monkey-patch getMode. Rather, it'd be possible to define a javascriptmixed mode which wraps the javascript mode much like htmlmixed wraps xml, and switches to an inner mode when specific (configurable) types of tagged templates are encountered.

@ForbesLindesay
Copy link
Contributor Author

That sounds like a good approach, we could then request brackets move to javascriptmixed as the default JavaScript mode.

@marijnh marijnh closed this as completed Feb 25, 2015
@leeoniya
Copy link
Contributor

leeoniya commented Sep 1, 2015

+1 for a javascriptmixed and also for re-opening this issue.

embedding html and other template languages in js is getting pretty common as libraries move away from pure vdom-building to faster strategies that diff only dynamic parts of templates. would be cool to get html highlighting in Codemirror for libs like t7 [1] and also enable JSX [2].

[1] https://github.com/trueadm/t7
[2] #3122

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants