dropkiq
Version:
Liquid Expressions Simplified
1 lines • 2.36 kB
JavaScript
;var __extends=this&&this.__extends||function(){var e=function(t,r){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),__generator=this&&this.__generator||function(e,t){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(a){return function(s){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,s])}}};Object.defineProperty(exports,"__esModule",{value:!0});var underscore_1=require("../../util/underscore"),assert_1=require("../../util/assert"),template_1=require("../../template/template"),types_1=require("../../types"),Tag=function(e){function t(r,n,o){var a=e.call(this,r)||this;a.name=r.name;var i=t.impls[r.name];return assert_1.assert(i,"tag "+r.name+" not found"),a.impl=Object.create(i),a.impl.liquid=o,a.impl.parse&&a.impl.parse(r,n),a}return __extends(t,e),t.prototype.render=function(e,t){var r,n;return __generator(this,(function(o){switch(o.label){case 0:return[4,types_1.Hash.create(this.token.args,e)];case 1:return r=o.sent(),n=this.impl,underscore_1.isFunction(n.render)?[4,n.render(e,r,t)]:[3,3];case 2:return[2,o.sent()];case 3:return[2]}}))},t.register=function(e,r){t.impls[e]=r},t.clear=function(){t.impls={}},t.impls={},t}(template_1.Template);exports.Tag=Tag;