Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Update Juicer to 0.6.5-stable [1.3]. #146

Merged
merged 1 commit into from

3 participants

@PaulGuo

No description provided.

@jayli jayli merged commit 0129a25 into kissygalleryteam:master
@PaulGuo

是否需要重新build? gallery-build中的文件还未更新。

@yiminghe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 3, 2013
  1. @PaulGuo
This page is out of date. Refresh to see the latest.
View
106 gallery/juicer/1.3/CHANGELOG.md
@@ -0,0 +1,106 @@
+Juicer Change History
+=====================
+
+
+0.4.0
+-----
+
+* Added `register` and `unregister` methods to manage the customed method.
+
+* Resolved `__escapehtml` global pollution.
+
+
+0.5.0
+-----
+
+* Added `#id` support for tpl parameter.
+
+* Support custom the tags by `juicer.set('tag::someTag', 'yourTag')`.
+
+* Fixed `each … range` bug that ranges are incorrect.
+
+0.5.1
+-----
+
+* Fixed `#id` support invalid bug because of `var document`.
+
+* Fixed `lexical analyze` bug (`Issue #3`), for example: `{@if a == b}` will throw b is undefined.
+
+0.5.2
+-----
+
+* Fixed `lexical analyze` bug (`Issue #4`), for example: `{@if a == true}` will throw `Unexpected token true`.
+
+* Fixed `lexical analyze` bug (`Issue #5`), for example: `{@else if a == b}` will throw a is undefined.
+
+0.5.3
+-----
+
+* Added `arguments support` when using helper function (`Pull #6`).
+
+* Added `Object each operation support`.
+
+0.5.4
+-----
+
+* Update `whitelist` for lexicalAnalyze.
+
+0.5.5
+-----
+
+* Fixed `window` is not defined warning under expressjs.
+* Added `expressjs` wrapper, and demo.
+
+0.5.6
+-----
+
+* Fixed `Object each operation` bug.
+
+0.5.7
+-----
+
+* Compatible for `avoid re-declare native function` for node.js.
+
+0.5.8
+-----
+
+* Fixed `varialble outer each statement environment` bug (`Issue #8`), for example: `{@each array as item}${item}{@/each}${item}`.
+
+0.5.9
+-----
+
+* avoid re-declare registered function, if not do this, template `{@if registered_func(name)}` could be throw undefined.
+
+0.6.0
+-----
+
+* fixed bug for Firefox 14.0.1 (`issue #9`, https://bugzilla.mozilla.org/show_bug.cgi?id=785822).
+* added adapter for expressjs-3.x.
+
+0.6.1
+-----
+
+* avoid re-analyze method statement variable.
+
+0.6.2
+-----
+
+* fixed bug that variable support in `each .. range` expression (`issue #16`).
+* added sub-template support using `{@include sub, data}`.
+
+0.6.3
+-----
+
+* update testcase of sub-template support.
+* added command line support for node.js, using for precompile the template files, `npm install -g juicer`.
+
+0.6.4
+-----
+
+* fixed bug that `if(console)` detection will throw error under some browser (like ie6).
+
+0.6.5
+-----
+
+* added `other helper types support`, not only the function type, but also can be object type, etc. fixed `variableAnalyze` for `object[variable]` statement.
+
View
12 gallery/juicer/1.3/build.xml
@@ -0,0 +1,12 @@
+<project name="pagination.build" default="build" basedir=".">
+ <description>Component Build File</description>
+
+ <property name="src.dir" value="."/>
+ <property name="component.name" value="juicer"/>
+ <property name="component.version" value="1.3"/>
+
+ <import file="../../common.xml"/>
+
+ <target name="build" depends="common.build">
+ </target>
+</project>
View
146 gallery/juicer/1.3/demo.html
@@ -0,0 +1,146 @@
+<!doctype html>
+<html>
+<head>
+ <meta charset="utf-8"/>
+ <title>KISSY gallery - Juicer</title>
+
+ <link rel="stylesheet" href="http://a.tbcdn.cn/s/kissy/1.3.0/css/dpl/base-min.css"/>
+ <link rel="stylesheet" href="../../../tools/skin/default.css"/>
+ <style>
+ h4 {
+ font-size: 14px;
+ font-weight: bold;
+ margin-bottom: 10px;
+ }
+ textarea {
+ border: 1px solid #BBBBBB;
+ font-family: Inconsolata,monaco,courier;
+ font-size: 12px;
+ height: 280px;
+ margin-bottom: 20px;
+ padding: 5px;
+ width: 800px;
+ }
+ </style>
+ <script src="http://a.tbcdn.cn/s/kissy/1.3.0/kissy.js" charset="utf-8"></script>
+ <script>
+ KISSY.config({
+ packages:[
+ {
+ name:"gallery",
+ tag:"20130403",
+ path:"../../../", // cdn上适当修改对应路径
+ charset:"utf-8"
+ }
+ ]
+ });
+ </script>
+ <link rel="stylesheet" href="../../../tools/skin/show-code.js"/>
+
+</head>
+<body>
+ <div id="header">
+ <h1 class="logo"><a alt="KISSY" href="http://kissyui.com/"><img src="http://a.tbcdn.cn/s/kissy/logo.png"/></a></h1>
+ <div class="sub-title">Gallery</div>
+ <ul class="navigation">
+ <li><a href="http://blog.kissyui.com/">博客</a></li>
+ <li><a href="http://github.com/kissyteam">源码</a></li>
+ </ul>
+
+ </div>
+ <div id="content">
+ <div class="s-crumbs">
+ <span>当前位置:</span>
+ <a href="http://kissyui.com/">KISSY</a>
+ <a href="../../../index.html">Gallery</a>
+ <span>Juicer</span>
+ </div>
+ <pre class="s-section">
+Author: liuhuo.gk@taobao.com (流火)
+Description:juicer is a lightweight javascript template engine, it’s fast and easy to use. it’s syntax like smarty, it can running either at browser or node.js
+Docs : <a href="http://juicer.name/docs/docs.html">doc</a>
+Source code: <a href="juicer.js">juicer.js</a></pre>
+
+ <h3 class="s-title">Demo - 使用 Juicer 渲染模版</h3>
+ <div class="s-section">
+ <div class="s-demo">
+ <div>
+
+<h4>Juicer 模版:</h4>
+
+<textarea id="template">
+<h1>${header}</h1>
+{@if bug}
+{@/if}
+{@each items as it}
+ {@if it.first}
+ <li><strong>${it.name}</strong></li>
+ {@/if}
+ {@if it.link}
+ <li><a href="${it.url}">${it.name}</a></li>
+ {@/if}
+{@/each}
+{@if empty}
+ <p>The list is empty.</p>
+{@/if}
+</textarea>
+
+<h4>JSON 数据:</h4>
+
+<textarea id="data">
+{
+ "header": "Colors",
+ "items": [
+ {"name": "red", "first": true, "url": "#Red"},
+ {"name": "green", "link": true, "url": "#Green"},
+ {"name": "blue", "link": true, "url": "#Blue"}
+ ],
+ "empty": false
+}
+</textarea>
+
+<h4>渲染结果:</h4>
+<pre id="juicer"></pre>
+
+ </div>
+
+ <script>
+ KISSY.use('gallery/juicer/1.3/',function(S, juicer){
+ var template = S.one('#template').html(),
+ data = S.JSON.parse(S.one('#data').html()),
+ html = juicer(template, data);
+
+ S.one('#juicer').html(html.replace(/^\s*/mg, ''));
+ });
+ </script>
+ </div>
+ <a class="s-view-code" href="demo.html#">显示源码</a><!--点击该链接自动帮你显示s=demo里的内容,如不需要,去除链接即可-->
+ </div>
+
+ <h3 class="s-title">API</h3>
+ <div class="s-section">
+ <h4 class="s-api-title">方法</h4>
+ <div class="s-api-method"> juicer(template,data)</div>
+ <h4 class="s-api-title">参数</h4>
+ <div class="s-api-params">
+ <ul class="s-list">
+ <li>{String} [ <em>template</em> ] 模版字符串</li>
+ <li>{JSON} [ <em>data</em> ] 模版数据</li>
+ </ul>
+ </div>
+ <h4 class="s-api-title">返回</h4>
+ <div class="s-api-return">{String} 渲染后的字符串</div>
+ </div>
+
+ <h3 class="s-title">Note</h3>
+ <div class="s-section">
+ <ul class="s-list">
+ <li>http://juicer.name/</li>
+ </ul>
+ </div>
+ </div>
+ <div id="footer">
+ &copy; Copyright 2010~2012, KISSY Team.
+ </div>
+</body>
+</html>
View
5 gallery/juicer/1.3/index.js
@@ -0,0 +1,5 @@
+KISSY.add("gallery/juicer/1.3/index",function(S, Juicer) {
+ return Juicer;
+}, {
+ requires:["./juicer"]
+});
View
488 gallery/juicer/1.3/juicer.js
@@ -0,0 +1,488 @@
+/*
+ ********** Juicer **********
+ ${A Fast template engine}
+ Project Home: http://juicer.name
+
+ Author: Guokai
+ Gtalk: badkaikai@gmail.com
+ Blog: http://benben.cc
+ Licence: MIT License
+ Version: 0.6.5-stable
+*/
+
+KISSY.add('gallery/juicer/1.3/juicer',function(S) {
+
+ // This is the main function for not only compiling but also rendering.
+ // there's at least two parameters need to be provided, one is the tpl,
+ // another is the data, the tpl can either be a string, or an id like #id.
+ // if only tpl was given, it'll return the compiled reusable function.
+ // if tpl and data were given at the same time, it'll return the rendered
+ // result immediately.
+
+ var juicer = function() {
+ var args = [].slice.call(arguments);
+
+ args.push(juicer.options);
+
+ if(args[0].match(/^\s*#([\w:\-\.]+)\s*$/igm)) {
+ args[0].replace(/^\s*#([\w:\-\.]+)\s*$/igm, function($, $id) {
+ var _document = document;
+ var elem = _document && _document.getElementById($id);
+ args[0] = elem ? (elem.value || elem.innerHTML) : $;
+ });
+ }
+
+ if(arguments.length == 1) {
+ return juicer.compile.apply(juicer, args);
+ }
+
+ if(arguments.length >= 2) {
+ return juicer.to_html.apply(juicer, args);
+ }
+ };
+
+ var __escapehtml = {
+ escapehash: {
+ '<': '&lt;',
+ '>': '&gt;',
+ '&': '&amp;',
+ '"': '&quot;',
+ "'": '&#x27;',
+ '/': '&#x2f;'
+ },
+ escapereplace: function(k) {
+ return __escapehtml.escapehash[k];
+ },
+ escaping: function(str) {
+ return typeof(str) !== 'string' ? str : str.replace(/[&<>"]/igm, this.escapereplace);
+ },
+ detection: function(data) {
+ return typeof(data) === 'undefined' ? '' : data;
+ }
+ };
+
+ var __throw = function(error) {
+ if(typeof(console) !== 'undefined') {
+ if(console.warn) {
+ console.warn(error);
+ return;
+ }
+
+ if(console.log) {
+ console.log(error);
+ return;
+ }
+ }
+
+ throw(error);
+ };
+
+ var __creator = function(o, proto) {
+ o = o !== Object(o) ? {} : o;
+
+ if(o.__proto__) {
+ o.__proto__ = proto;
+ return o;
+ }
+
+ var empty = function() {};
+ var n = Object.create ?
+ Object.create(proto) :
+ new(empty.prototype = proto, empty);
+
+ for(var i in o) {
+ if(o.hasOwnProperty(i)) {
+ n[i] = o[i];
+ }
+ }
+
+ return n;
+ };
+
+ juicer.__cache = {};
+ juicer.version = '0.6.5-stable';
+ juicer.settings = {};
+
+ juicer.tags = {
+ operationOpen: '{@',
+ operationClose: '}',
+ interpolateOpen: '\\${',
+ interpolateClose: '}',
+ noneencodeOpen: '\\$\\${',
+ noneencodeClose: '}',
+ commentOpen: '\\{#',
+ commentClose: '\\}'
+ };
+
+ juicer.options = {
+ cache: true,
+ strip: true,
+ errorhandling: true,
+ detection: true,
+ _method: __creator({
+ __escapehtml: __escapehtml,
+ __throw: __throw,
+ __juicer: juicer
+ }, {})
+ };
+
+ juicer.tagInit = function() {
+ var forstart = juicer.tags.operationOpen + 'each\\s*([^}]*?)\\s*as\\s*(\\w*?)\\s*(,\\s*\\w*?)?' + juicer.tags.operationClose;
+ var forend = juicer.tags.operationOpen + '\\/each' + juicer.tags.operationClose;
+ var ifstart = juicer.tags.operationOpen + 'if\\s*([^}]*?)' + juicer.tags.operationClose;
+ var ifend = juicer.tags.operationOpen + '\\/if' + juicer.tags.operationClose;
+ var elsestart = juicer.tags.operationOpen + 'else' + juicer.tags.operationClose;
+ var elseifstart = juicer.tags.operationOpen + 'else if\\s*([^}]*?)' + juicer.tags.operationClose;
+ var interpolate = juicer.tags.interpolateOpen + '([\\s\\S]+?)' + juicer.tags.interpolateClose;
+ var noneencode = juicer.tags.noneencodeOpen + '([\\s\\S]+?)' + juicer.tags.noneencodeClose;
+ var inlinecomment = juicer.tags.commentOpen + '[^}]*?' + juicer.tags.commentClose;
+ var rangestart = juicer.tags.operationOpen + 'each\\s*(\\w*?)\\s*in\\s*range\\(([^}]+?)\\s*,\\s*([^}]+?)\\)' + juicer.tags.operationClose;
+ var include = juicer.tags.operationOpen + 'include\\s*([^}]*?)\\s*,\\s*([^}]*?)' + juicer.tags.operationClose;
+
+ juicer.settings.forstart = new RegExp(forstart, 'igm');
+ juicer.settings.forend = new RegExp(forend, 'igm');
+ juicer.settings.ifstart = new RegExp(ifstart, 'igm');
+ juicer.settings.ifend = new RegExp(ifend, 'igm');
+ juicer.settings.elsestart = new RegExp(elsestart, 'igm');
+ juicer.settings.elseifstart = new RegExp(elseifstart, 'igm');
+ juicer.settings.interpolate = new RegExp(interpolate, 'igm');
+ juicer.settings.noneencode = new RegExp(noneencode, 'igm');
+ juicer.settings.inlinecomment = new RegExp(inlinecomment, 'igm');
+ juicer.settings.rangestart = new RegExp(rangestart, 'igm');
+ juicer.settings.include = new RegExp(include, 'igm');
+ };
+
+ juicer.tagInit();
+
+ // Using this method to set the options by given conf-name and conf-value,
+ // you can also provide more than one key-value pair wrapped by an object.
+ // this interface also used to custom the template tag delimater, for this
+ // situation, the conf-name must begin with tag::, for example: juicer.set
+ // ('tag::operationOpen', '{@').
+
+ juicer.set = function(conf, value) {
+ var that = this;
+
+ var escapePattern = function(v) {
+ return v.replace(/[\$\(\)\[\]\+\^\{\}\?\*\|\.]/igm, function($) {
+ return '\\' + $;
+ });
+ };
+
+ var set = function(conf, value) {
+ var tag = conf.match(/^tag::(.*)$/i);
+
+ if(tag) {
+ that.tags[tag[1]] = escapePattern(value);
+ that.tagInit();
+ return;
+ }
+
+ that.options[conf] = value;
+ };
+
+ if(arguments.length === 2) {
+ set(conf, value);
+ return;
+ }
+
+ if(conf === Object(conf)) {
+ for(var i in conf) {
+ if(conf.hasOwnProperty(i)) {
+ set(i, conf[i]);
+ }
+ }
+ }
+ };
+
+ // Before you're using custom functions in your template like ${name | fnName},
+ // you need to register this fn by juicer.register('fnName', fn).
+
+ juicer.register = function(fname, fn) {
+ var _method = this.options._method;
+
+ if(_method.hasOwnProperty(fname)) {
+ return false;
+ }
+
+ return _method[fname] = fn;
+ };
+
+ // remove the registered function in the memory by the provided function name.
+ // for example: juicer.unregister('fnName').
+
+ juicer.unregister = function(fname) {
+ var _method = this.options._method;
+
+ if(_method.hasOwnProperty(fname)) {
+ return delete _method[fname];
+ }
+ };
+
+ juicer.template = function(options) {
+ var that = this;
+
+ this.options = options;
+
+ this.__interpolate = function(_name, _escape, options) {
+ var _define = _name.split('|'), _fn = _define[0] || '', _cluster;
+
+ if(_define.length > 1) {
+ _name = _define.shift();
+ _cluster = _define.shift().split(',');
+ _fn = '_method.' + _cluster.shift() + '.call({}, ' + [_name].concat(_cluster) + ')';
+ }
+
+ return '<%= ' + (_escape ? '_method.__escapehtml.escaping' : '') + '(' +
+ (!options || options.detection !== false ? '_method.__escapehtml.detection' : '') + '(' +
+ _fn +
+ ')' +
+ ')' +
+ ' %>';
+ };
+
+ this.__removeShell = function(tpl, options) {
+ var _counter = 0;
+
+ tpl = tpl
+ // for expression
+ .replace(juicer.settings.forstart, function($, _name, alias, key) {
+ var alias = alias || 'value', key = key && key.substr(1);
+ var _iterate = 'i' + _counter++;
+ return '<% ~function() {' +
+ 'for(var ' + _iterate + ' in ' + _name + ') {' +
+ 'if(' + _name + '.hasOwnProperty(' + _iterate + ')) {' +
+ 'var ' + alias + '=' + _name + '[' + _iterate + '];' +
+ (key ? ('var ' + key + '=' + _iterate + ';') : '') +
+ ' %>';
+ })
+ .replace(juicer.settings.forend, '<% }}}(); %>')
+
+ // if expression
+ .replace(juicer.settings.ifstart, function($, condition) {
+ return '<% if(' + condition + ') { %>';
+ })
+ .replace(juicer.settings.ifend, '<% } %>')
+
+ // else expression
+ .replace(juicer.settings.elsestart, function($) {
+ return '<% } else { %>';
+ })
+
+ // else if expression
+ .replace(juicer.settings.elseifstart, function($, condition) {
+ return '<% } else if(' + condition + ') { %>';
+ })
+
+ // interpolate without escape
+ .replace(juicer.settings.noneencode, function($, _name) {
+ return that.__interpolate(_name, false, options);
+ })
+
+ // interpolate with escape
+ .replace(juicer.settings.interpolate, function($, _name) {
+ return that.__interpolate(_name, true, options);
+ })
+
+ // clean up comments
+ .replace(juicer.settings.inlinecomment, '')
+
+ // range expression
+ .replace(juicer.settings.rangestart, function($, _name, start, end) {
+ var _iterate = 'j' + _counter++;
+ return '<% ~function() {' +
+ 'for(var ' + _iterate + '=' + start + ';' + _iterate + '<' + end + ';' + _iterate + '++) {{' +
+ 'var ' + _name + '=' + _iterate + ';' +
+ ' %>';
+ })
+
+ // include sub-template
+ .replace(juicer.settings.include, function($, tpl, data) {
+ return '<%= _method.__juicer(' + tpl + ', ' + data + '); %>';
+ });
+
+ // exception handling
+ if(!options || options.errorhandling !== false) {
+ tpl = '<% try { %>' + tpl;
+ tpl += '<% } catch(e) {_method.__throw("Juicer Render Exception: "+e.message);} %>';
+ }
+
+ return tpl;
+ };
+
+ this.__toNative = function(tpl, options) {
+ return this.__convert(tpl, !options || options.strip);
+ };
+
+ this.__lexicalAnalyze = function(tpl) {
+ var buffer = [];
+ var method = [];
+ var prefix = '';
+ var reserved = [
+ 'if', 'each', '_', '_method', 'console',
+ 'break', 'case', 'catch', 'continue', 'debugger', 'default', 'delete', 'do',
+ 'finally', 'for', 'function', 'in', 'instanceof', 'new', 'return', 'switch',
+ 'this', 'throw', 'try', 'typeof', 'var', 'void', 'while', 'with', 'null', 'typeof',
+ 'class', 'enum', 'export', 'extends', 'import', 'super', 'implements', 'interface',
+ 'let', 'package', 'private', 'protected', 'public', 'static', 'yield', 'const', 'arguments',
+ 'true', 'false', 'undefined', 'NaN'
+ ];
+
+ var indexOf = function(array, item) {
+ if (Array.prototype.indexOf && array.indexOf === Array.prototype.indexOf) {
+ return array.indexOf(item);
+ }
+
+ for(var i=0; i < array.length; i++) {
+ if(array[i] === item) return i;
+ }
+
+ return -1;
+ };
+
+ var variableAnalyze = function($, statement) {
+ statement = statement.match(/\w+/igm)[0];
+
+ if(indexOf(buffer, statement) === -1 && indexOf(reserved, statement) === -1 && indexOf(method, statement) === -1) {
+
+ // avoid re-declare native function, if not do this, template
+ // `{@if encodeURIComponent(name)}` could be throw undefined.
+
+ if(typeof(window) !== 'undefined' && typeof(window[statement]) === 'function' && window[statement].toString().match(/^\s*?function \w+\(\) \{\s*?\[native code\]\s*?\}\s*?$/i)) {
+ return $;
+ }
+
+ // compatible for node.js
+ if(typeof(global) !== 'undefined' && typeof(global[statement]) === 'function' && global[statement].toString().match(/^\s*?function \w+\(\) \{\s*?\[native code\]\s*?\}\s*?$/i)) {
+ return $;
+ }
+
+ // avoid re-declare registered function, if not do this, template
+ // `{@if registered_func(name)}` could be throw undefined.
+
+ if(typeof(juicer.options._method[statement]) === 'function' || juicer.options._method.hasOwnProperty(statement)) {
+ method.push(statement);
+ return $;
+ }
+
+ buffer.push(statement); // fuck ie
+ }
+
+ return $;
+ };
+
+ tpl.replace(juicer.settings.forstart, variableAnalyze).
+ replace(juicer.settings.interpolate, variableAnalyze).
+ replace(juicer.settings.ifstart, variableAnalyze).
+ replace(juicer.settings.elseifstart, variableAnalyze).
+ replace(juicer.settings.include, variableAnalyze).
+ replace(/[\+\-\*\/%!\?\|\^&~<>=,\(\)\[\]]\s*([A-Za-z_]+)/igm, variableAnalyze);
+
+ for(var i = 0;i < buffer.length; i++) {
+ prefix += 'var ' + buffer[i] + '=_.' + buffer[i] + ';';
+ }
+
+ for(var i = 0;i < method.length; i++) {
+ prefix += 'var ' + method[i] + '=_method.' + method[i] + ';';
+ }
+
+ return '<% ' + prefix + ' %>';
+ };
+
+ this.__convert=function(tpl, strip) {
+ var buffer = [].join('');
+
+ buffer += "'use strict';"; // use strict mode
+ buffer += "var _=_||{};";
+ buffer += "var _out='';_out+='";
+
+ if(strip !== false) {
+ buffer += tpl
+ .replace(/\\/g, "\\\\")
+ .replace(/[\r\t\n]/g, " ")
+ .replace(/'(?=[^%]*%>)/g, "\t")
+ .split("'").join("\\'")
+ .split("\t").join("'")
+ .replace(/<%=(.+?)%>/g, "';_out+=$1;_out+='")
+ .split("<%").join("';")
+ .split("%>").join("_out+='")+
+ "';return _out;";
+
+ return buffer;
+ }
+
+ buffer += tpl
+ .replace(/\\/g, "\\\\")
+ .replace(/[\r]/g, "\\r")
+ .replace(/[\t]/g, "\\t")
+ .replace(/[\n]/g, "\\n")
+ .replace(/'(?=[^%]*%>)/g, "\t")
+ .split("'").join("\\'")
+ .split("\t").join("'")
+ .replace(/<%=(.+?)%>/g, "';_out+=$1;_out+='")
+ .split("<%").join("';")
+ .split("%>").join("_out+='")+
+ "';return _out.replace(/[\\r\\n]\\s+[\\r\\n]/g, '\\r\\n');";
+
+ return buffer;
+ };
+
+ this.parse = function(tpl, options) {
+ var _that = this;
+
+ if(!options || options.loose !== false) {
+ tpl = this.__lexicalAnalyze(tpl) + tpl;
+ }
+
+ tpl = this.__removeShell(tpl, options);
+ tpl = this.__toNative(tpl, options);
+
+ this._render = new Function('_, _method', tpl);
+
+ this.render = function(_, _method) {
+ if(!_method || _method !== that.options._method) {
+ _method = __creator(_method, that.options._method);
+ }
+
+ return _that._render.call(this, _, _method);
+ };
+
+ return this;
+ };
+ };
+
+ juicer.compile = function(tpl, options) {
+ if(!options || options !== this.options) {
+ options = __creator(options, this.options);
+ }
+
+ try {
+ var engine = this.__cache[tpl] ?
+ this.__cache[tpl] :
+ new this.template(this.options).parse(tpl, options);
+
+ if(!options || options.cache !== false) {
+ this.__cache[tpl] = engine;
+ }
+
+ return engine;
+
+ } catch(e) {
+ __throw('Juicer Compile Exception: ' + e.message);
+
+ return {
+ render: function() {} // noop
+ };
+ }
+ };
+
+ juicer.to_html = function(tpl, data, options) {
+ if(!options || options !== this.options) {
+ options = __creator(options, this.options);
+ }
+
+ return this.compile(tpl, options).render(data, options._method);
+ };
+
+ return juicer;
+});
View
4 gallery/juicer/index.html
@@ -1,3 +1,3 @@
<script>
- window.location='./1.2/demo.html';
-</script>
+ window.location='./1.3/demo.html';
+</script>
Something went wrong with that request. Please try again.