dropkiq
Version:
Liquid Expressions Simplified
1 lines • 3.12 kB
JavaScript
"use strict";var __generator=this&&this.__generator||function(e,r){var t,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function l(o){return function(l){return function(o){if(t)throw new TypeError("Generator is already executing.");for(;a;)try{if(t=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=r.call(e,a)}catch(e){o=[6,e],n=0}finally{t=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,l])}}},__values=this&&this.__values||function(e){var r="function"==typeof Symbol&&Symbol.iterator,t=r&&e[r],n=0;if(t)return t.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")},__read=this&&this.__read||function(e,r){var t="function"==typeof Symbol&&e[Symbol.iterator];if(!t)return e;var n,i,o=t.call(e),a=[];try{for(;(void 0===r||r-- >0)&&!(n=o.next()).done;)a.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(t=o.return)&&t.call(o)}finally{if(i)throw i.error}}return a},__spread=this&&this.__spread||function(){for(var e=[],r=0;r<arguments.length;r++)e=e.concat(__read(arguments[r]));return e};Object.defineProperty(exports,"__esModule",{value:!0});var expression_1=require("../../render/expression"),underscore_1=require("../../util/underscore"),Filter=function(){function e(r,t,n){var i=e.impls[r];if(!i&&n)throw new TypeError("undefined filter: "+r);this.name=r,this.impl=i||underscore_1.identify,this.args=t}return e.prototype.render=function(e,r){var t,n,i,o,a,l,s,u,c,f,p,h;return __generator(this,(function(y){switch(y.label){case 0:t=[],y.label=1;case 1:y.trys.push([1,8,9,10]),n=__values(this.args),i=n.next(),y.label=2;case 2:return i.done?[3,7]:isKeyValuePair(o=i.value)?(l=(a=t).push,s=[o[0]],[4,new expression_1.Expression(o[1]).evaluate(r)]):[3,4];case 3:return l.apply(a,[s.concat([y.sent()])]),[3,6];case 4:return c=(u=t).push,[4,new expression_1.Expression(o).evaluate(r)];case 5:c.apply(u,[y.sent()]),y.label=6;case 6:return i=n.next(),[3,2];case 7:return[3,10];case 8:return f=y.sent(),p={error:f},[3,10];case 9:try{i&&!i.done&&(h=n.return)&&h.call(n)}finally{if(p)throw p.error}return[7];case 10:return[2,this.impl.apply({context:r},__spread([e],t))]}}))},e.register=function(r,t){e.impls[r]=t},e.clear=function(){e.impls={}},e.impls={},e}();function isKeyValuePair(e){return underscore_1.isArray(e)}exports.Filter=Filter;