JQuery's $ is in conflict with that of StringTemplate.Net in ASP.Net MVC

I am exploring ASP.NET MVC and I wanted to add jQuery to make the site interactive. I used StringTemplate, ported to .Net, as my template engine to generate html and to send JSON. However, when I view the page, I could not see it. After debugging, I've realized that the $ is used by the StringTemplate to access property, etc and jQuery uses it too to manipulate the DOM. Gee, I've looked on other template engines and most of them uses the dollar sign :(.

Any alternative template engine for ASP.Net MVC? I wanted to retain jQuery because MSFT announced that it will used in the Visual Studio (2008?)

Thanks in Advance :)

Update

Please go to the answer in ASP.NET MVC View Engine Comparison question for a comprehensive list of Template engine for ASP.NET MVC, and their pros and cons

Update 2

At the end I'll just put the JavaScript code, including JQuery, in a separate script file, hence I wouldn't worry about the $ mingling in the template file.

Update 3

Changed the Title to reflect what I need to resolve. After all "The Best X in Y" is very subjective question.


You can of course move your js logic into a .js file. But if you want it inline with your StringTemplate views, you can escape it using the \$ construct.

In addition, you can simply use the jQuery("selector"), instead of $("selector") construct if you want to avoid the escaping syntax.

Here's a good article on using StringTemplate as a View Engine in MVC.

There's also an accompanying OpenSource engine, along with some samples.

Also, as mentioned above, you can modify your Type Lexer. (make it an alternate character to the $).


I would highly recommend Spark. I've been using it for awhile now with jQuery and haven't ran into a single issue so far.


JQuery can be disambiguated by using the jQuery keyword like this:

jQuery(

instead of this:

$(

I would consider this a best practice. It eliminates any possibility of clashing with another library, and makes the code more readable.