jQuery Template Plugin or custom functions?
What I've got are chunks of code that are used over and over again in HTML. For example:
<div class="row">
<span class="label"></span>
<span class="control">
<!-- content here -->
</span>
</div>
Here we have a simple row that I use in forms. Naturally, this chunk of code happens over and over, page after page. I'm essentially writing this out with jQuery for my dynamic content.开发者_如何学JAVA
Now, I ran across jQuery Templates and thought for a moment that this was my solution. However, the fact that you have to declare your templates within a script block WITHIN your .htm page... not good. I want total separation.
So what I'm asking is: what is the best way to accomplish essentially the same thing as a template but with a custom function or class? Or is this even necessary?
You can have your templates as separate html files that are loaded asynchronously (which you can set cache headers on appropriately), here's how to do it.
You could try to apply my solution: http://github.com/mpapis/jquery-pure-templates
I'm also interested in extending it for other uses if you are interested.
精彩评论