-
Notifications
You must be signed in to change notification settings - Fork 1
vkTemplate is a very small, simple and powerful template solution for web applications.
vkiryukhin/vkTemplate
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
**vkTemplate - jQuery Plugin** **Version** - 0.94.00 ( ECMAScript-5 strict mode compatible) **Copyright** (c) 2010 - 2012 Vadim Kiryukhin ( vkiryukhin @ gmail.com ) **project's home page:** http://www.eslinstructor.net/vktemplate/ Dual licensed under the MIT and GPL licenses: http://www.opensource.org/licenses/mit-license.php http://www.gnu.org/licenses/gpl.html --- - No configuration is needed - Include in the page head: < script type="text/javascript" src="vktemplate.js"></script> - **Usage format:** $('#container').vkTemplate(tmpl, jsonData [, params] [, callback] [, context]); - **Parameters:** - @tmpl - template URL address or element's ID; - @jsonData: possible types are: - URL address of the data. - JSON string; - JSON object; - @params - jQuery Ajax "data" parameter that is sent to the server with jsonData URL if needed (optional) - @callback - callback function (optional) - @context - context object (optional) - **Usage Examples:** $('#container').vkTemplate(tmpl, jsonData); // JSON as URL $('#container').vkTemplate(tmpl, '{"foo":"bar"}'); // JSON as a string $('#container').vkTemplate(tmpl, {foo:"bar"}); // JSON as an object $('#container').vkTemplate(tmpl, jsonData, function(){...}); // callback function $('#container').vkTemplate(tmpl, jsonData, {id:123}); // jsonData is URL with extra parameters $('#container').vkTemplate(tmpl, jsonData, {id:123}, function(){...}); // jsonData is URL, extra parameters are provided; callback function. If context is passed, all five arguments must be provided. If you don't need one or both optional arguments, set it/them to null. - $('#foo').vkTemplate('basic.tmpl','basic.php',null,null, cntx); - $('#foo').vkTemplate('basic.tmpl','basic.php',null,function(){...}, cntx); - $('#foo').vkTemplate('basic.tmpl','basic.php',{foo:"bar"},null, cntx); - **Template syntax:** - javascript logic is wrapped with <% ... > - stuff which should be printed is wrapped with <%= ... > - **Template object prefix:** use 'o.' prefix to refer json object object: {first_name:"John",state:"California"} template: Hi <%=o.first_name> Welcom to <%=o.state>! - **Template Examples:** <%=o.first_name%> <%=o.last_name%> <%for(var ix=0;ix<o.time.length;ix++) {%> time is: <%=o.time[ix].h%>:<%=o.time[ix].m%>:<%=o.time[ix].s%> <%}%> <%if (o.first_name == "Ann") {%> . . . <%} else {%> . . . <%}%>
About
vkTemplate is a very small, simple and powerful template solution for web applications.
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published