I've been using jQuery templates which I absolutely love to use. The only drawback from an IDE standpoint is the lack of HTML IntelliSense inside the script tag. Is there a way to fool VS2010 so that markup inside template script tags get IntelliSense and syntax highlighting?
相关问题
- Views base64 encoded blob in HTML with PHP
- How to fix IE ClearType + jQuery opacity problem i
- jQuery add and remove delay
- Is there a way to play audio on a mobile browser w
- HTML form is not sending $_POST values
If you're using MVC you can make an extension method for the HtmlHelper like this:
Use like
You'll get full syntax coloring and intellisense that way. (though, VS might warn about invalid nesting of html elements depending on what your templates consist of)
Another WebForms solution, not as thorough or elegant as Rusted's solution, but I drop these two functions inside of a BasePage class from which all my other pages inherit:
Then in my aspx:
I'd solved this issue by creating simple custom serverside control (for ASP.NET 4 WebForms app.):
and put each jquery template inside it (instead of
<script>
tag):will rendered it in HTML as:
I don't think you can unless you trick the editor to not know you are writing a script tag, like writing it in code (HTML helper or so). I'd work around it by changing the tag name (or commenting it) temporarily and bringing it back after I'm done. Sure that's a silly solution.
One other thing you can do is instead of using
script
tag, use any other tag likediv
setting it'sstyle
todisplay:none
. It should work exactly the same way (example in middle of this article).I created a helper method for ASP.NET MVC 3 that works like this, inspired by Html.BeginForm:
within the view:
Anything within the @using scope will be syntax highlighted.
The code for the helper: