Skip to content
A jQuery Plugin for loading external jQote2 templates.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
build
example
src
test
.gitignore
LICENSE.txt
README.md
jquery.jqote2.loader-min.js

README.md

#jQote2 Template Loader A jQuery Plugin for loading external jQote2 templates.

Example

Using the jQote2 Template Loader plugin is rather straight forward. Simply include jQuery, jQote2and the jquery.jqote2.loader-min.js script on your page.

For this example, assume a file named "example.tpl" exists, which contains the following template definition:

<script type="text/html" id="articles_tpl">
	<![CDATA[
    	<% var article, i, n;
    	   
    	   for ( i = 0, n = this.articles.length; i < n; i++ ) {
			     article = this.articles[i]; 
		 %>
			<article>
				<header>
					<h1><%= article.name %></h1>
				</header>
				<p><%= article.text %></p>
			</article>
        <% } %>
	]]>
</script>

We can load the "example.tpl" template file described above via $.jqoteload as follows:

$.jqoteload( 'example.tpl', function( templates )
{
	// create some mock articles...
	var articles = [ { name: 'Article A', text: 'Articles A test...'},
					 { name: 'Article B', text: 'Articles B test...'},
					 { name: 'Article C', text: 'Articles C test...'} ];
    // Render the articles...
    $('#articles').jqoteapp( templates.articles_tpl, { 'articles': articles } );
});

After "example.tpl" has been loaded, from another context we can access the compiled templates via their template element id. In this example "articles_tpl".

//... within some other context, access the same compiled template
var template = $.jqoteret( 'articles_tpl' );

The above example can be found in the examples directory.

Note

jQote2 needs a CDN, vote for it :).

You can’t perform that action at this time.