jquery - Using jTemplate with ASP.NET MVC -


In

, Dave Ward explains that what he calls "client side rapper" to use the jquery plugin , Which parses JSON data on a client side in a template.

At the end of the article, he suggests that the template extension is placed in a separate file with ".tpl", and that the data is loaded into the document with the following syntax:

 apply the function to the template (jsonData) {// in this method the HTML template loads and // creates the container device to accept the data. $ ('# Container') setTemplateURL ('myTemplate.tpl'). // This method applies the JSON array to the container's template and it presents $ ('# container') processTemplate (jsonData). } 

However, when I am using ASP.NET MVC, I can not just place the template file next to my view and I can call it with "/Guestbook/myTemplate.tpl". But I would like to have a template file next to the will view, together to keep everything together.

How can I organize it? A controller action that returns text file content? Global.assx to create a framework Some configurations in C return only these files without parsing the controller / action URL? Any other ideas?

I suggest using .htm instead. It comes in a default MVC app properly.

It has been found that due to some versions of IIS, this is a bad idea. Until Tpl is blocked as an unknown file type, unless you explicitly add it. I need to update my post.


Comments