-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
HTML string inside TypeScript and JavaScript files? #2000
Comments
👍 |
I copied the item to the TS repository to hear their opinion: microsoft/TypeScript#6778 |
Consider using templateUrl, and specifying a HTML file name. You can then get all the autocomplete in that HTML file. I think that is better than mixing code and HTML like Classic ASP. Example: |
I don't know if this would help in VSCodes case, but @GregOnNet came up with a brilliant solution for adding HTML highlighting to the TypeStrong/atom-typescript#948 Hoping that might help potentially add this ability to VSCode! |
@aeschli please see the latest comment. With what we discussed last week can we achieve the same? |
In the meantime looks like this extension works pretty well: |
True, it doesn't autocomplete html but at least it'll help you with variables you have within that file. Let's say you had |
Just for other people finding this thread the link above is the working one. The other extension from the same author no longer works with the current version of vscode as far as I know. The extension does provide:
But sadly NO formatting. There is an open feature request for formatting, give it some love if you also wanne see it included too: natewallace/angular2-inline#6 |
Is it desirable to turn this into a more generic solution? What if my backtick contained some JS code for evaulating (yuck), or more likely, I'm providing some inline scripting to an Elasticsearch query? |
@robhaswell SQL would be awesome too! |
This would be quite useful for hyperHTML/viperHTML and lit-html as well https://github.com/PolymerLabs/lit-html |
Meanwhile I found this. https://github.com/Microsoft/typescript-lit-html-plugin |
Yes, for angular try the angular-inline extension and for lit-html, try:
I posted more information about embedded language support in #5961 (comment) as well. To sum up, you can already write extensions and TypeScript plugins that contribute support for embedded languages. The main remaining work is to polish the experience so that you only need to install a single vscode extension to get syntax highlighting and intellisense for your template strings. This work is now being tracked by #5961 Closing this issue in favor of #5961 |
When using Angular 2 and TypeScript I noticed that editing
template
strings of components in TypeScript files are not working as one expect. There is not autocomplete for tags and other usual HTML editing features.For example
Of course it's because the type definition has declared
template
as a String and no part of VSCode knows that it's an HTML string.My proposal is to define a
HTMLString
type where it's basically just string but helps tooling in cases like this.If it was possible to do this, then we can define
CSSString
,JavaScriptString
,SCSSString
and so on...The text was updated successfully, but these errors were encountered: