Altering resig js tmpl library. JSP has a hate passion for it.
parent
f3e53386f9
commit
c015329e52
|
@ -65,26 +65,26 @@
|
||||||
|
|
||||||
<script type="text/html" id="client_tmpl">
|
<script type="text/html" id="client_tmpl">
|
||||||
<tr>
|
<tr>
|
||||||
<td><%=name%></td>
|
<td><#=name#></td>
|
||||||
<td><%=redirectURL%></td>
|
<td><#=redirectURL#></td>
|
||||||
<td>
|
<td>
|
||||||
<ul>
|
<ul>
|
||||||
<% for (var i in grantType) { %>
|
<# for (var i in grantType) { #>
|
||||||
<li><%=grantType[i]%></li>
|
<li><#=grantType[i]#></li>
|
||||||
<% } %>
|
<# } #>
|
||||||
</ul>
|
</ul>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<ul>
|
<ul>
|
||||||
<% for (var i in scope) { %>
|
<# for (var i in scope) { #>
|
||||||
<li><%=scope[i]%></li>
|
<li><#=scope[i]#></li>
|
||||||
<% } %>
|
<# } #>
|
||||||
</ul>
|
</ul>
|
||||||
</td>
|
</td>
|
||||||
<td><%=authority%></td>
|
<td><#=authority#></td>
|
||||||
<td><%=description%>
|
<td><#=description#>
|
||||||
</td>
|
</td>
|
||||||
<td><input type="checkbox" "<%=(refreshTokens == 1 ? 'checked' : '')%> value="" id="" name="" disabled></td>
|
<td><input type="checkbox" "<#=(refreshTokens == 1 ? 'checked' : '')#> value="" id="" name="" disabled></td>
|
||||||
<td>
|
<td>
|
||||||
<button data-controls-modal="modal-from-dom" data-backdrop="true" data-keyboard="true"
|
<button data-controls-modal="modal-from-dom" data-backdrop="true" data-keyboard="true"
|
||||||
class="btn">edit
|
class="btn">edit
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
|
// A slightly modified version of the Resig Templating library
|
||||||
|
// JSP hates the original
|
||||||
|
|
||||||
// Simple JavaScript Templating
|
// Simple JavaScript Templating
|
||||||
// John Resig - http://ejohn.org/ - MIT Licensed
|
// John Resig - http://ejohn.org/ - MIT Licensed
|
||||||
(function() {
|
(function(){
|
||||||
var cache = {};
|
var cache = {};
|
||||||
|
|
||||||
this.tmpl = function tmpl(str, data) {
|
this.tmpl = function tmpl(str, data){
|
||||||
// Figure out if we're getting a template, or if we need to
|
// Figure out if we're getting a template, or if we need to
|
||||||
// load the template - and be sure to cache the result.
|
// load the template - and be sure to cache the result.
|
||||||
var fn = !/\W/.test(str) ?
|
var fn = !/\W/.test(str) ?
|
||||||
|
@ -19,16 +22,18 @@
|
||||||
"with(obj){p.push('" +
|
"with(obj){p.push('" +
|
||||||
|
|
||||||
// Convert the template into pure JavaScript
|
// Convert the template into pure JavaScript
|
||||||
str.replace(/[\r\t\n]/g, " ")
|
str
|
||||||
.replace(/'(?=[^%]*%>)/g,"\t")
|
.replace(/[\r\t\n]/g, " ")
|
||||||
|
.replace(/'(?=[^#]*#>)/g, "\t")
|
||||||
.split("'").join("\\'")
|
.split("'").join("\\'")
|
||||||
.split("\t").join("'")
|
.split("\t").join("'")
|
||||||
.replace(/<%=(.+?)%>/g, "',$1,'")
|
.replace(/<#=(.+?)#>/g, "',$1,'")
|
||||||
.split("<%").join("');")
|
.split("<#").join("');")
|
||||||
.split("%>").join("p.push('")
|
.split("#>").join("p.push('")
|
||||||
|
.split("\r").join("\\'")
|
||||||
+ "');}return p.join('');");
|
+ "');}return p.join('');");
|
||||||
|
|
||||||
// Provide some basic currying to the user
|
// Provide some basic currying to the user
|
||||||
return data ? fn(data) : fn;
|
return data ? fn( data ) : fn;
|
||||||
};
|
};
|
||||||
})();
|
})();
|
Loading…
Reference in New Issue