Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support for json string is added. documentation is done.
- Loading branch information
1 parent
db73c6b
commit 5a3916c
Showing
31 changed files
with
675 additions
and
558 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<table> | ||
<tr><td> | ||
<div class="h6">Condition</div> | ||
Click on "Conditions" menu item several times to see how it works. | ||
</td></tr> | ||
<tr ><td class="functionDoc"> | ||
<div class="h5">JSON:</div><pre><code> | ||
{"h":"04","m":"20","s":"22"} | ||
</code></pre> | ||
</td></tr><tr><td class="templateDoc"> | ||
<div class="h5">Template:</div> | ||
<pre><code> | ||
Current time is: <%=h%>:<%=m%>:<%=s%> | ||
|
||
<%if (s%2) {%> | ||
odd second | ||
<%} else {%> | ||
even second | ||
<%}%> | ||
</code></pre> | ||
</td></tr> | ||
<tr ><td class="jsonDoc"> | ||
<div class="h5">Function:</div> | ||
<code> | ||
$('#leftpanel').vkTemplate('condition.tmpl','condition.php'); | ||
</code> | ||
</td></tr></table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<style type="text/css"> | ||
#doc {margin:1em;} | ||
#doc ul li {margin:0.5em;} | ||
</style> | ||
<div id="doc"> | ||
<div class="h6">Documentation</div> | ||
<p> | ||
|
||
<ul> | ||
<li>No configuration is needed</li> | ||
<li>Include in the page head: <code><script type="text/javascript" src="vktemplate.js"></script></code> | ||
|
||
<li>Usage format: <code>$('#container').vkTemplate(urlTemplate, jsonData [, callback]);</code> | ||
|
||
</li> | ||
<li>Parameters: | ||
<ul> | ||
<li><code>@urlTemplate</code> - URL address to get template;</li> | ||
|
||
<li><code>@jsonData</code>:<br/> | ||
- URL address to get data.<br/> | ||
- JSON string; | ||
</li> | ||
<li><code>@callback</code> - callback function (optional)</li> | ||
</ul> | ||
</li> | ||
|
||
<li>Usage Examples: | ||
<ul> | ||
<li><code>$('#container').vkTemplate(urlTemplate, urlJsonData);</code></li> | ||
<li><code>$('#container').vkTemplate(urlTemplate, '{"foo":"bar"}');</code></li> | ||
<li><code>$('#container').vkTemplate(urlTemplate, urlJsonData, function(){...});</code></li> | ||
</ul> | ||
</li> | ||
<li>Template syntax: | ||
<ul> | ||
<li>javascript logic is wrapped with <b><% ... ></b><br/></li> | ||
<li>stuff which should be printed is wrapped with <b><%= ... ></b></li> | ||
</ul> | ||
</li> | ||
<li>Template Examples: | ||
<ul> | ||
<li><code><%=first_name%> <%=last_name%>></code></li> | ||
<li><pre><code><%for(var ix=0;ix<time.length;ix++) {%> | ||
time is: <%=time[ix].h%>:<%=time[ix].m%>:<%=time[ix].s%> | ||
<%}%></code></pre> | ||
</li> | ||
</ul> | ||
</li> | ||
</ul> | ||
|
||
</p> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<table> | ||
<tr><td> | ||
<div class="h6">Empty String</div> | ||
<p>Parameter "state" in JSON is empty, but it doesn't crash application.</p> | ||
</td></tr> | ||
<tr ><td class="functionDoc"> | ||
<div class="h5">JSON:</div> | ||
<code> | ||
{ "first_name":"Vadim", "last_name":"Kiryukhin", <span class="highlight">"state":""</span>} | ||
</code> | ||
</td></tr><tr><td class="templateDoc"> | ||
<div class="h5">Template:</div> | ||
<code> | ||
My name is <%=first_name%> <%=last_name%>. | ||
Greeting from <%=state%>! | ||
</code> | ||
</td></tr> | ||
<tr ><td class="jsonDoc"> | ||
<div class="h5">Function:</div> | ||
<code> | ||
$('#leftpanel').vkTemplate('basic.tmpl','empty_string.php'); | ||
</code> | ||
</td></tr></table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<table> | ||
<tr><td> | ||
<div class="h6">Integration</div> | ||
<p> | ||
This is an example of a very simple web application, which performs periodical updating functionality. Every 2 seconds it takes time from a server and display it. I use jQuery <a href="http://eslinstructor.net/smartupdater3/" target="_blank">Smartupdater</a> plugin to implement polling mechanism. | ||
</p> | ||
</td></tr> | ||
<tr ><td class="functionDoc"> | ||
<div class="h5">JSON:</div><pre><code> | ||
{"h":"06","m":"10","s":"05"} | ||
</code></pre> | ||
</td></tr><tr><td class="templateDoc"> | ||
<div class="h5">Template:</div> | ||
<pre><code> | ||
<%=h%>:<%=m%>:<%=s%> | ||
</code></pre> | ||
</td></tr> | ||
<tr ><td class="jsonDoc"> | ||
<div class="h5">Function:</div> | ||
<pre><code> | ||
<div id="timedisplay"></div> | ||
|
||
<script type="text/javascript"> | ||
$("#timedisplay").<span class="highlight">smartupdater</span>({ | ||
url: 'php/get_time.php',<span class="comment"> // url to data </span> | ||
minTimeout: 2000 <span class="comment"> // 2 seconds</span> | ||
}, function (data) { | ||
<span class="highlight">$('#timedisplay').vkTemplate('tmpl/time.tmpl',data);</span> | ||
} | ||
); | ||
</script> | ||
</code></pre> | ||
</td></tr></table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<table> | ||
<tr><td> | ||
<div class="h6">Overview</div> | ||
<p> | ||
vkTemplate is a very small, very simple and very powerful template solution for web applications. | ||
<ul> | ||
<li> <b>Small:</b> 65 lines of code, 1.1 k if minified<br/><br/></li> | ||
<li><b>Simple interface:</b> only one function with 2 parameters: <i>template</i> and <i>data</i> (the third parameter: <i>callback function</i> is optional)<br/><br/></li> | ||
<li> <b>Power:</b> well known and popular micro-template engin written by John Resig ( http://ejohn.org ) is used in this plugin as a core function. </li> | ||
</ul> | ||
|
||
Template syntax: | ||
<ul> | ||
<li>javascript logic is wrapped with <b><% ... ></b><br/><br/></li> | ||
<li>stuff which should be printed is wrapped with <b><%= ... ></b></li> | ||
</ul> | ||
|
||
Data format is: <b>JSON</b> | ||
</p> | ||
|
||
</td></tr></table> |
Oops, something went wrong.