views:

31

answers:

2

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.

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?

+1  A: 

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.

Nick Craver