jscoverage

96.46756583172768%
1557
1502
55

lib/index.js

100%
43
43
0
Line Hits Source
1 // Generated by CoffeeScript 1.7.1
2 1 (function() {
3 1 var Liquid, customError, util;
4
5 1 Liquid = require("./liquid");
6
7 1 util = require("util");
8
9 1 customError = function(name, inherit) {
10 9 var error;
11 if (inherit == null) {
12 1 inherit = global.Error;
13 }
14 9 error = function(message) {
15 19 this.name = name;
16 19 this.message = message;
17 if (global.Error.captureStackTrace) {
18 19 return global.Error.captureStackTrace(this, arguments.callee);
19 }
20 };
21 9 util.inherits(error, inherit);
22 9 return error;
23 };
24
25 1 Liquid.Error = customError("Error");
26
27 1 ["ArgumentError", "ContextError", "FilterNotFound", "FilterNotFound", "FileSystemError", "StandardError", "StackLevelError", "SyntaxError"].forEach(function(className) {
28 8 return Liquid[className] = customError("Liquid." + className, Liquid.Error);
29 });
30
31 1 Liquid.Engine = require("./liquid/engine");
32
33 1 Liquid.Helpers = require("./liquid/helpers");
34
35 1 Liquid.Range = require("./liquid/range");
36
37 1 Liquid.Iterable = require("./liquid/iterable");
38
39 1 Liquid.Drop = require("./liquid/drop");
40
41 1 Liquid.Context = require("./liquid/context");
42
43 1 Liquid.Tag = require("./liquid/tag");
44
45 1 Liquid.Block = require("./liquid/block");
46
47 1 Liquid.Document = require("./liquid/document");
48
49 1 Liquid.Variable = require("./liquid/variable");
50
51 1 Liquid.Template = require("./liquid/template");
52
53 1 Liquid.StandardFilters = require("./liquid/standard_filters");
54
55 1 Liquid.Condition = require("./liquid/condition");
56
57 1 Liquid.ElseCondition = require("./liquid/else_condition");
58
59 1 Liquid.Assign = require("./liquid/tags/assign");
60
61 1 Liquid.Capture = require("./liquid/tags/capture");
62
63 1 Liquid.Comment = require("./liquid/tags/comment");
64
65 1 Liquid.Decrement = require("./liquid/tags/decrement");
66
67 1 Liquid.For = require("./liquid/tags/for");
68
69 1 Liquid.If = require("./liquid/tags/if");
70
71 1 Liquid.Ifchanged = require("./liquid/tags/ifchanged");
72
73 1 Liquid.Increment = require("./liquid/tags/increment");
74
75 1 Liquid.Raw = require("./liquid/tags/raw");
76
77 1 Liquid.Unless = require("./liquid/tags/unless");
78
79 1 module.exports = Liquid;
80
81 }).call(this);
82
83 //# sourceMappingURL=index.map
84

lib/liquid.js

100%
77
77
0
Line Hits Source
1 // Generated by CoffeeScript 1.7.1
2 1 (function() {
3 1 var Liquid;
4
5 1 module.exports = Liquid = (function() {
6 function Liquid() {}
7
8 1 Liquid.FilterSeparator = /\|/;
9
10 1 Liquid.ArgumentSeparator = /,/;
11
12 1 Liquid.FilterArgumentSeparator = /\:/;
13
14 1 Liquid.VariableAttributeSeparator = /\./;
15
16 1 Liquid.TagStart = /\{\%/;
17
18 1 Liquid.TagEnd = /\%\}/;
19
20 1 Liquid.VariableSignature = /\(?[\w\-\.\[\]]\)?/;
21
22 1 Liquid.VariableSegment = /[\w\-]/;
23
24 1 Liquid.VariableStart = /\{\{/;
25
26 1 Liquid.VariableEnd = /\}\}/;
27
28 1 Liquid.VariableIncompleteEnd = /\}\}?/;
29
30 1 Liquid.QuotedString = /"[^"]*"|'[^']*'/;
31
32 1 Liquid.QuotedFragment = RegExp("" + Liquid.QuotedString.source + "|(?:[^\\s,\\|'\"]|" + Liquid.QuotedString.source + ")+");
33
34 1 Liquid.StrictQuotedFragment = /"[^"]+"|'[^']+'|[^\s|:,]+/;
35
36 1 Liquid.FirstFilterArgument = RegExp("" + Liquid.FilterArgumentSeparator.source + "(?:" + Liquid.StrictQuotedFragment.source + ")");
37
38 1 Liquid.OtherFilterArgument = RegExp("" + Liquid.ArgumentSeparator.source + "(?:" + Liquid.StrictQuotedFragment.source + ")");
39
40 1 Liquid.SpacelessFilter = RegExp("^(?:'[^']+'|\"[^\"]+\"|[^'\"])*" + Liquid.FilterSeparator.source + "(?:" + Liquid.StrictQuotedFragment.source + ")(?:" + Liquid.FirstFilterArgument.source + "(?:" + Liquid.OtherFilterArgument.source + ")*)?");
41
42 1 Liquid.Expression = RegExp("(?:" + Liquid.QuotedFragment.source + "(?:" + Liquid.SpacelessFilter.source + ")*)");
43
44 1 Liquid.TagAttributes = RegExp("(\\w+)\\s*\\:\\s*(" + Liquid.QuotedFragment.source + ")");
45
46 1 Liquid.AnyStartingTag = /\{\{|\{\%/;
47
48 1 Liquid.PartialTemplateParser = RegExp("" + Liquid.TagStart.source + ".*?" + Liquid.TagEnd.source + "|" + Liquid.VariableStart.source + ".*?" + Liquid.VariableIncompleteEnd.source);
49
50 1 Liquid.TemplateParser = RegExp("(" + Liquid.PartialTemplateParser.source + "|" + Liquid.AnyStartingTag.source + ")");
51
52 1 Liquid.VariableParser = RegExp("\\[[^\\]]+\\]|" + Liquid.VariableSegment.source + "+\\??");
53
54 1 return Liquid;
55
56 })();
57
58 }).call(this);
59
60 //# sourceMappingURL=liquid.map
61

lib/liquid/block.js

99.23076923076923%
130
129
1
Line Hits Source
1 // Generated by CoffeeScript 1.7.1
2 1 (function() {
3 1 var Block, Liquid, Promise, util,
4 __hasProp = {}.hasOwnProperty,
5 5 __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
6
7 1 Liquid = require("../liquid");
8
9 1 util = require("util");
10
11 1 Promise = require("bluebird");
12
13 1 module.exports = Block = (function(_super) {
14 1 __extends(Block, _super);
15
16 function Block() {
17 85 return Block.__super__.constructor.apply(this, arguments);
18 }
19
20 1 Block.IsTag = RegExp("^" + Liquid.TagStart.source);
21
22 1 Block.IsVariable = RegExp("^" + Liquid.VariableStart.source);
23
24 1 Block.FullToken = RegExp("^" + Liquid.TagStart.source + "\\s*(\\w+)\\s*(.*)?" + Liquid.TagEnd.source + "$");
25
26 1 Block.ContentOfVariable = RegExp("^" + Liquid.VariableStart.source + "(.*)" + Liquid.VariableEnd.source + "$");
27
28 1 Block.prototype.beforeParse = function() {
29 if (this.nodelist == null) {
30 122 this.nodelist = [];
31 }
32 196 return this.nodelist.length = 0;
33 };
34
35 1 Block.prototype.afterParse = function() {
36 186 return this.assertMissingDelimitation();
37 };
38
39 1 Block.prototype.parse = function(tokens) {
40 497 var token;
41 if (tokens.length === 0 || this.ended) {
42 184 return Promise.cast();
43 }
44 313 token = tokens.shift();
45 313 return Promise["try"]((function(_this) {
46 313 return function() {
47 313 return _this.parseToken(token, tokens);
48 };
49 })(this))["catch"](function(e) {
50 10 e.message = "" + e.message + "\n at " + token.value + " (" + token.filename + ":" + token.line + ":" + token.col + ")";
51 if (e.location == null) {
52 8 e.location = {
53 col: token.col,
54 line: token.line,
55 filename: token.filename
56 };
57 }
58 10 throw e;
59 }).then((function(_this) {
60 313 return function() {
61 303 return _this.parse(tokens);
62 };
63 })(this));
64 };
65
66 1 Block.prototype.parseToken = function(token, tokens) {
67 313 var Tag, match, tag;
68 if (Block.IsTag.test(token.value)) {
69 185 match = Block.FullToken.exec(token.value);
70 if (!match) {
71 1 throw new Liquid.SyntaxError("Tag '" + token.value + "' was not properly terminated with regexp: " + Liquid.TagEnd.inspect);
72 }
73 if (this.blockDelimiter() === match[1]) {
74 80 return this.endTag();
75 }
76 104 Tag = this.template.tags[match[1]];
77 if (!Tag) {
78 11 return this.unknownTag(match[1], match[2], tokens);
79 }
80 93 tag = new Tag(this.template, match[1], match[2]);
81 93 this.nodelist.push(tag);
82 93 return tag.parseWithCallbacks(tokens);
83 } else if (Block.IsVariable.test(token.value)) {
84 53 return this.nodelist.push(this.createVariable(token));
85 } else if (token.value.length === 0) {
86
87 } else {
88 75 return this.nodelist.push(token.value);
89 }
90 };
91
92 1 Block.prototype.endTag = function() {
93 82 return this.ended = true;
94 };
95
96 1 Block.prototype.unknownTag = function(tag, params, tokens) {
97 if (tag === 'else') {
98 1 throw new Liquid.SyntaxError("" + (this.blockName()) + " tag does not expect else tag");
99 } else if (tag === 'end') {
100 1 throw new Liquid.SyntaxError("'end' is not a valid delimiter for " + (this.blockName()) + " tags. use " + (this.blockDelimiter()));
101 } else {
102 3 throw new Liquid.SyntaxError("Unknown tag '" + tag + "'");
103 }
104 };
105
106 1 Block.prototype.blockDelimiter = function() {
107 100 return "end" + (this.blockName());
108 };
109
110 1 Block.prototype.blockName = function() {
111 103 return this.tagName;
112 };
113
114 1 Block.prototype.createVariable = function(token) {
115 53 var match, _ref;
116 53 match = (_ref = Liquid.Block.ContentOfVariable.exec(token.value)) != null ? _ref[1] : void 0;
117 if (match) {
118 52 return new Liquid.Variable(match);
119 }
120 1 throw new Liquid.SyntaxError("Variable '" + token.value + "' was not properly terminated with regexp: " + Liquid.VariableEnd.inspect);
121 };
122
123 1 Block.prototype.render = function(context) {
124 98 return this.renderAll(this.nodelist, context);
125 };
126
127 1 Block.prototype.assertMissingDelimitation = function() {
128 if (!this.ended) {
129 1 throw new Liquid.SyntaxError("" + (this.blockName()) + " tag was never closed");
130 }
131 };
132
133 1 Block.prototype.renderAll = function(list, context) {
134 226 return Promise.map(list, function(token) {
135 if (typeof (token != null ? token.render : void 0) !== "function") {
136 73 return token;
137 }
138 202 return Promise["try"](function() {
139 202 return token.render(context);
140 })["catch"](function(e) {
141 1 return context.handleError(e);
142 });
143 }, {
144 concurrency: 1
145 });
146 };
147
148 1 return Block;
149
150 })(Liquid.Tag);
151
152 }).call(this);
153
154 //# sourceMappingURL=block.map
155

lib/liquid/condition.js

100%
98
98
0
Line Hits Source
1 // Generated by CoffeeScript 1.7.1
2 1 (function() {
3 1 var Condition, Liquid, Promise;
4
5 1 Liquid = require("../liquid");
6
7 1 Promise = require("bluebird");
8
9 1 module.exports = Condition = (function() {
10 1 var LITERALS;
11
12 1 Condition.operators = {
13 '==': function(cond, left, right) {
14 14 return cond.equalVariables(left, right);
15 },
16 'is': function(cond, left, right) {
17 1 return cond.equalVariables(left, right);
18 },
19 '!=': function(cond, left, right) {
20 3 return !cond.equalVariables(left, right);
21 },
22 '<>': function(cond, left, right) {
23 1 return !cond.equalVariables(left, right);
24 },
25 'isnt': function(cond, left, right) {
26 1 return !cond.equalVariables(left, right);
27 },
28 '<': function(cond, left, right) {
29 1 return left < right;
30 },
31 '>': function(cond, left, right) {
32 1 return left > right;
33 },
34 '<=': function(cond, left, right) {
35 2 return left <= right;
36 },
37 '>=': function(cond, left, right) {
38 2 return left >= right;
39 },
40 'contains': function(cond, left, right) {
41 4 return (left != null ? typeof left.indexOf === "function" ? left.indexOf(right) : void 0 : void 0) >= 0;
42 }
43 };
44
45 function Condition(left, operator, right) {
46 62 this.left = left;
47 62 this.operator = operator;
48 62 this.right = right;
49 62 this.childRelation = null;
50 62 this.childCondition = null;
51 }
52
53 1 Condition.prototype.evaluate = function(context) {
54 59 var result;
55 if (context == null) {
56 1 context = new Liquid.Context();
57 }
58 59 result = this.interpretCondition(this.left, this.right, this.operator, context);
59 switch (this.childRelation) {
60 case "or":
61 4 return Promise.cast(result).then((function(_this) {
62 4 return function(result) {
63 4 return result || _this.childCondition.evaluate(context);
64 };
65 })(this));
66 case "and":
67 6 return Promise.cast(result).then((function(_this) {
68 6 return function(result) {
69 6 return result && _this.childCondition.evaluate(context);
70 };
71 })(this));
72 default:
73 48 return result;
74 }
75 };
76
77 1 Condition.prototype.or = function(childCondition) {
78 4 this.childCondition = childCondition;
79 4 return this.childRelation = "or";
80 };
81
82 1 Condition.prototype.and = function(childCondition) {
83 6 this.childCondition = childCondition;
84 6 return this.childRelation = "and";
85 };
86
87 1 Condition.prototype.attach = function(attachment) {
88 51 return this.attachment = attachment;
89 };
90
91 1 Condition.prototype.equalVariables = function(left, right) {
92 if (typeof left === "function") {
93 2 return left(right);
94 } else if (typeof right === "function") {
95 4 return right(left);
96 } else {
97 14 return left === right;
98 }
99 };
100
101 1 LITERALS = {
102 empty: function(v) {
103 3 return !((v != null ? v.length : void 0) > 0);
104 },
105 blank: function(v) {
106 3 return !v || v.toString().length === 0;
107 }
108 };
109
110 1 Condition.prototype.resolveVariable = function(v, context) {
111 if (v in LITERALS) {
112 6 return Promise.cast(LITERALS[v]);
113 } else {
114 82 return context.get(v);
115 }
116 };
117
118 1 Condition.prototype.interpretCondition = function(left, right, op, context) {
119 59 var operation;
120 if (op == null) {
121 28 return this.resolveVariable(left, context);
122 }
123 31 operation = Condition.operators[op];
124 if (operation == null) {
125 1 throw new Error("Unknown operator " + op);
126 }
127 30 left = this.resolveVariable(left, context);
128 30 right = this.resolveVariable(right, context);
129 30 return Promise.join(left, right).spread((function(_this) {
130 30 return function(left, right) {
131 30 return operation(_this, left, right);
132 };
133 })(this));
134 };
135
136 1 return Condition;
137
138 })();
139
140 }).call(this);
141
142 //# sourceMappingURL=condition.map
143

lib/liquid/context.js

93.5361216730038%
263
246
17
Line Hits Source
1 // Generated by CoffeeScript 1.7.1
2 1 (function() {
3 1 var Context, Liquid, Promise,
4 __slice = [].slice,
5 __hasProp = {}.hasOwnProperty;
6
7 1 Liquid = require("../liquid");
8
9 1 Promise = require("bluebird");
10
11 1 module.exports = Context = (function() {
12 function Context(engine, environments, outerScope, registers, rethrowErrors) {
13 113 var _ref;
14 if (environments == null) {
15 19 environments = {};
16 }
17 if (outerScope == null) {
18 19 outerScope = {};
19 }
20 if (registers == null) {
21 19 registers = {};
22 }
23 if (rethrowErrors == null) {
24 19 rethrowErrors = false;
25 }
26 113 this.environments = Liquid.Helpers.flatten([environments]);
27 113 this.scopes = [outerScope];
28 113 this.registers = registers;
29 113 this.errors = [];
30 113 this.rethrowErrors = rethrowErrors;
31 113 this.strainer = (_ref = engine != null ? new engine.Strainer(this) : void 0) != null ? _ref : {};
32 113 this.squashInstanceAssignsWithEnvironments();
33 }
34
35 1 Context.prototype.registerFilters = function() {
36 2 var filter, filters, k, v, _i, _len;
37 2 filters = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
38 for (_i = 0, _len = filters.length; _i < _len; _i++) {
39 1 filter = filters[_i];
40 for (k in filter) {
41 if (!__hasProp.call(filter, k)) continue;
42 2 v = filter[k];
43 if (v instanceof Function) {
44 2 this.strainer[k] = v;
45 }
46 }
47 }
48 };
49
50 1 Context.prototype.handleError = function(e) {
51 5 this.errors.push(e);
52 if (this.rethrowErrors) {
53 1 throw e;
54 }
55 if (e instanceof Liquid.SyntaxError) {
56 1 return "Liquid syntax error: " + e.message;
57 } else {
58 3 return "Liquid error: " + e.message;
59 }
60 };
61
62 1 Context.prototype.invoke = function() {
63 8 var args, available, method, methodName;
64 8 methodName = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
65 8 method = this.strainer[methodName];
66 if (method instanceof Function) {
67 7 return method.apply(this.strainer, args);
68 } else {
69 1 available = Object.keys(this.strainer);
70 1 throw new Liquid.FilterNotFound("Unknown filter `" + methodName + "`, available: [" + (available.join(', ')) + "]");
71 }
72 };
73
74 1 Context.prototype.push = function(newScope) {
75 if (newScope == null) {
76 101 newScope = {};
77 }
78 196 this.scopes.unshift(newScope);
79 if (this.scopes.length > 100) {
80 1 throw new Error("Nesting too deep");
81 }
82 };
83
84 1 Context.prototype.merge = function(newScope) {
85 2 var k, v, _results;
86 if (newScope == null) {
87 1 newScope = {};
88 }
89 2 _results = [];
90 for (k in newScope) {
91 if (!__hasProp.call(newScope, k)) continue;
92 2 v = newScope[k];
93 2 _results.push(this.scopes[0][k] = v);
94 }
95 2 return _results;
96 };
97
98 1 Context.prototype.pop = function() {
99 if (this.scopes.length <= 1) {
100 1 throw new Error("ContextError");
101 }
102 92 return this.scopes.shift();
103 };
104
105 1 Context.prototype.lastScope = function() {
106 119 return this.scopes[this.scopes.length - 1];
107 };
108
109 1 Context.prototype.stack = function(newScope, f) {
110 87 var popLater, result;
111 if (newScope == null) {
112 1 newScope = {};
113 }
114 87 popLater = false;
115 try {
116 if (arguments.length < 2) {
117 86 f = newScope;
118 86 newScope = {};
119 }
120 87 this.push(newScope);
121 87 result = f();
122 if ((result != null ? result.nodeify : void 0) != null) {
123 86 popLater = true;
124 86 result.nodeify((function(_this) {
125 86 return function() {
126 86 return _this.pop();
127 };
128 })(this));
129 }
130 87 return result;
131 } finally {
132 if (!popLater) {
133 1 this.pop();
134 }
135 }
136 };
137
138 1 Context.prototype.clearInstanceAssigns = function() {
139 1 return this.scopes[0] = {};
140 };
141
142 1 Context.prototype.set = function(key, value) {
143 157 return this.scopes[0][key] = value;
144 };
145
146 1 Context.prototype.get = function(key) {
147 218 return this.resolve(key);
148 };
149
150 1 Context.prototype.hasKey = function(key) {
151 4 return Promise.cast(this.resolve(key)).then(function(v) {
152 4 return v != null;
153 });
154 };
155
156 1 Context.Literals = {
157 'null': null,
158 'nil': null,
159 '': null,
160 'true': true,
161 'false': false
162 };
163
164 1 Context.prototype.resolve = function(key) {
165 236 var hi, lo, match;
166 if (Liquid.Context.Literals.hasOwnProperty(key)) {
167 4 return Liquid.Context.Literals[key];
168 } else if (match = /^'(.*)'$/.exec(key)) {
169 6 return match[1];
170 } else if (match = /^"(.*)"$/.exec(key)) {
171 5 return match[1];
172 } else if (match = /^(\d+)$/.exec(key)) {
173 28 return Number(match[1]);
174 } else if (match = /^\((\S+)\.\.(\S+)\)$/.exec(key)) {
175 3 lo = this.resolve(match[1]);
176 3 hi = this.resolve(match[2]);
177 3 return Promise.join(lo, hi).spread(function(lo, hi) {
178 3 lo = Number(lo);
179 3 hi = Number(hi);
180 if (isNaN(lo) || isNaN(hi)) {
181 1 return [];
182 }
183 2 return new Liquid.Range(lo, hi + 1);
184 });
185 } else if (match = /^(\d[\d\.]+)$/.exec(key)) {
186 1 return Number(match[1]);
187 } else {
188 189 return this.variable(key);
189 }
190 };
191
192 1 Context.prototype.findVariable = function(key) {
193 192 var variable, variableScope;
194 192 variableScope = void 0;
195 192 variable = void 0;
196 192 this.scopes.some(function(scope) {
197 if (scope.hasOwnProperty(key)) {
198 98 variableScope = scope;
199 98 return true;
200 }
201 });
202 if (variableScope == null) {
203 94 this.environments.some((function(_this) {
204 94 return function(env) {
205 96 variable = _this.lookupAndEvaluate(env, key);
206 if (variable != null) {
207 84 return variableScope = env;
208 }
209 };
210 })(this));
211 }
212 if (variableScope == null) {
213 if (this.environments.length > 0) {
214 10 variableScope = this.environments[this.environments.length - 1];
215 } else if (this.scopes.length > 0) {
216 0 variableScope = this.scopes[this.scopes.length - 1];
217 } else {
218 0 throw new Error("No scopes to find variable in.");
219 }
220 }
221 if (variable == null) {
222 108 variable = this.lookupAndEvaluate(variableScope, key);
223 }
224 192 return Promise.cast(variable).then((function(_this) {
225 192 return function(v) {
226 192 return _this.liquify(v);
227 };
228 })(this));
229 };
230
231 1 Context.prototype.variable = function(markup) {
232 192 return Promise["try"]((function(_this) {
233 192 return function() {
234 192 var firstPart, iterator, mapper, match, object, parts, squareBracketed;
235 192 parts = Liquid.Helpers.scan(markup, Liquid.VariableParser);
236 192 squareBracketed = /^\[(.*)\]$/;
237 192 firstPart = parts.shift();
238 if (match = squareBracketed.exec(firstPart)) {
239 0 firstPart = match[1];
240 }
241 192 object = _this.findVariable(firstPart);
242 if (parts.length === 0) {
243 134 return object;
244 }
245 58 mapper = function(part, object) {
246 if (object == null) {
247 0 return Promise.cast(object);
248 }
249 58 return Promise.cast(object).then(_this.liquify.bind(_this)).then(function(object) {
250 58 var bracketMatch;
251 if (object == null) {
252 0 return object;
253 }
254 58 bracketMatch = squareBracketed.exec(part);
255 if (bracketMatch) {
256 3 part = _this.resolve(bracketMatch[1]);
257 }
258 58 return Promise.cast(part).then(function(part) {
259 58 var isArrayAccess, isObjectAccess, isSpecialAccess;
260 58 isArrayAccess = Array.isArray(object) && isFinite(part);
261 58 isObjectAccess = object instanceof Object && ((typeof object.hasKey === "function" ? object.hasKey(part) : void 0) || part in object);
262 58 isSpecialAccess = !bracketMatch && object && (Array.isArray(object) || Object.prototype.toString.call(object) === "[object String]") && ["size", "first", "last"].indexOf(part) >= 0;
263 if (isArrayAccess || isObjectAccess) {
264 55 return Promise.cast(_this.lookupAndEvaluate(object, part)).then(_this.liquify.bind(_this));
265 } else if (isSpecialAccess) {
266 switch (part) {
267 case "size":
268 1 return _this.liquify(object.length);
269 case "first":
270 1 return _this.liquify(object[0]);
271 case "last":
272 1 return _this.liquify(object[object.length - 1]);
273 default:
274
275 /* @covignore */
276 throw new Error("Unknown special accessor: " + part);
277 }
278 } else {
279
280 /* @covignore */
281 throw new Error("Unknown access: " + part);
282 }
283 });
284 });
285 };
286 58 iterator = function(object, index) {
287 if (index < parts.length) {
288 58 return mapper(parts[index], object).then(function(object) {
289 58 return iterator(object, index + 1);
290 });
291 } else {
292 58 return Promise.cast(object);
293 }
294 };
295 58 return iterator(object, 0).then(null, function(err) {
296 0 throw new Error("Couldn't walk variable: " + markup + ": " + err);
297 });
298 };
299 })(this));
300 };
301
302 1 Context.prototype.lookupAndEvaluate = function(obj, key) {
303 if (obj instanceof Liquid.Drop) {
304 4 return obj.get(key);
305 } else {
306 255 return obj != null ? obj[key] : void 0;
307 }
308 };
309
310 1 Context.prototype.squashInstanceAssignsWithEnvironments = function() {
311 113 var lastScope;
312 113 lastScope = this.lastScope();
313 113 return Object.keys(lastScope).forEach((function(_this) {
314 113 return function(key) {
315 0 return _this.environments.some(function(env) {
316 if (env.hasOwnProperty(key)) {
317 0 lastScope[key] = _this.lookupAndEvaluate(env, key);
318 0 return true;
319 }
320 });
321 };
322 })(this));
323 };
324
325 1 Context.prototype.liquify = function(object) {
326 308 return Promise.cast(object).then((function(_this) {
327 308 return function(object) {
328 if (object == null) {
329 11 return object;
330 } else if (typeof object.toLiquid === "function") {
331 9 object = object.toLiquid();
332 } else if (typeof object === "object") {
333 139 true;
334 } else if (typeof object === "function") {
335 1 object = "";
336 } else {
337 148 Object.prototype.toString.call(object);
338 }
339 if (object instanceof Liquid.Drop) {
340 9 object.context = _this;
341 }
342 297 return object;
343 };
344 })(this));
345 };
346
347 1 return Context;
348
349 })();
350
351 }).call(this);
352
353 //# sourceMappingURL=context.map
354

lib/liquid/document.js

100%
11
11
0
Line Hits Source
1 // Generated by CoffeeScript 1.7.1
2 1 (function() {
3 1 var Liquid,
4 __hasProp = {}.hasOwnProperty,
5 5 __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
6
7 1 Liquid = require("../liquid");
8
9 1 module.exports = Liquid.Document = (function(_super) {
10 1 __extends(Document, _super);
11
12 function Document(template) {
13 111 this.template = template;
14 }
15
16 1 Document.prototype.blockDelimiter = function() {
17 91 return [];
18 };
19
20 1 Document.prototype.assertMissingDelimitation = function() {};
21
22 1 return Document;
23
24 })(Liquid.Block);
25
26 }).call(this);
27
28 //# sourceMappingURL=document.map
29

lib/liquid/drop.js

100%
36
36
0
Line Hits Source
1 // Generated by CoffeeScript 1.7.1
2 1 (function() {
3 1 var Drop;
4
5 1 module.exports = Drop = (function() {
6 function Drop() {}
7
8 1 Drop.prototype.context = null;
9
10 1 Drop.prototype.hasKey = function(key) {
11 4 return true;
12 };
13
14 1 Drop.prototype.invokeDrop = function(methodOrKey) {
15 4 var value;
16 if (this.constructor.isInvokable(methodOrKey)) {
17 2 value = this[methodOrKey];
18 if (typeof value === "function") {
19 1 return value.call(this);
20 } else {
21 1 return value;
22 }
23 } else {
24 2 return this.beforeMethod(methodOrKey);
25 }
26 };
27
28 1 Drop.prototype.beforeMethod = function(method) {};
29
30 1 Drop.isInvokable = function(method) {
31 if (this.invokableMethods == null) {
32 3 this.invokableMethods = (function(_this) {
33 3 return function() {
34 3 var blacklist, whitelist;
35 3 blacklist = Object.keys(Drop.prototype);
36 3 whitelist = ["toLiquid"];
37 3 Object.keys(_this.prototype).forEach(function(k) {
38 if (!(blacklist.indexOf(k) >= 0)) {
39 9 return whitelist.push(k);
40 }
41 });
42 3 return whitelist;
43 };
44 })(this)();
45 }
46 11 return this.invokableMethods.indexOf(method) >= 0;
47 };
48
49 1 Drop.prototype.get = function(methodOrKey) {
50 4 return this.invokeDrop(methodOrKey);
51 };
52
53 1 Drop.prototype.toLiquid = function() {
54 9 return this;
55 };
56
57 1 Drop.prototype.toString = function() {
58 1 return "[Liquid.Drop " + this.constructor.name + "]";
59 };
60
61 1 return Drop;
62
63 })();
64
65 }).call(this);
66
67 //# sourceMappingURL=drop.map
68

lib/liquid/else_condition.js

100%
10
10
0
Line Hits Source
1 // Generated by CoffeeScript 1.7.1
2 1 (function() {
3 1 var ElseCondition, Liquid,
4 __hasProp = {}.hasOwnProperty,
5 5 __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
6
7 1 Liquid = require("../liquid");
8
9 1 module.exports = ElseCondition = (function(_super) {
10 1 __extends(ElseCondition, _super);
11
12 function ElseCondition() {
13 5 return ElseCondition.__super__.constructor.apply(this, arguments);
14 }
15
16 1 ElseCondition.prototype.evaluate = function() {
17 2 return true;
18 };
19
20 1 return ElseCondition;
21
22 })(Liquid.Condition);
23
24 }).call(this);
25
26 //# sourceMappingURL=else_condition.map
27

lib/liquid/engine.js

94.73684210526315%
57
54
3
Line Hits Source
1 // Generated by CoffeeScript 1.7.1
2 1 (function() {
3 1 var Liquid, Promise,
4 __hasProp = {}.hasOwnProperty,
5 __slice = [].slice;
6
7 1 Liquid = require("../liquid");
8
9 1 Promise = require("bluebird");
10
11 1 module.exports = Liquid.Engine = (function() {
12 function Engine() {
13 115 var isBlockOrTagBaseClass, isSubclassOf, tag, tagName;
14 115 this.tags = {};
15 115 this.Strainer = function(context) {
16 97 this.context = context;
17 };
18 115 this.registerFilters(Liquid.StandardFilters);
19 115 isSubclassOf = function(klass, ofKlass) {
20 10925 var _ref;
21 if (typeof klass !== 'function') {
22 4830 return false;
23 } else if (klass === ofKlass) {
24 1495 return true;
25 } else {
26 4600 return isSubclassOf((_ref = klass.__super__) != null ? _ref.constructor : void 0, ofKlass);
27 }
28 };
29 for (tagName in Liquid) {
30 if (!__hasProp.call(Liquid, tagName)) continue;
31 6325 tag = Liquid[tagName];
32 if (!isSubclassOf(tag, Liquid.Tag)) {
33 4830 continue;
34 }
35 1495 isBlockOrTagBaseClass = [Liquid.Tag, Liquid.Block].indexOf(tag.constructor) >= 0;
36 if (!isBlockOrTagBaseClass) {
37 1495 this.registerTag(tagName.toLowerCase(), tag);
38 }
39 }
40 }
41
42 1 Engine.prototype.registerTag = function(name, tag) {
43 1495 return this.tags[name] = tag;
44 };
45
46 1 Engine.prototype.registerFilters = function() {
47 117 var filters;
48 117 filters = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
49 117 return filters.forEach((function(_this) {
50 117 return function(filter) {
51 117 var k, v, _results;
52 117 _results = [];
53 for (k in filter) {
54 if (!__hasProp.call(filter, k)) continue;
55 3682 v = filter[k];
56 if (v instanceof Function) {
57 3682 _results.push(_this.Strainer.prototype[k] = v);
58 } else {
59 0 _results.push(void 0);
60 }
61 }
62 117 return _results;
63 };
64 })(this));
65 };
66
67 1 Engine.prototype.parse = function(source) {
68 111 var template;
69 111 template = new Liquid.Template;
70 111 return template.parse(this, source);
71 };
72
73 1 Engine.prototype.parseAndRender = function() {
74 1 var args, source;
75 1 source = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
76 1 return this.parse(source).then(function(template) {
77 1 return template.render.apply(template, args);
78 });
79 };
80
81 1 return Engine;
82
83 })();
84
85 }).call(this);
86
87 //# sourceMappingURL=engine.map
88

lib/liquid/helpers.js

96.875%
32
31
1
Line Hits Source
1 // Generated by CoffeeScript 1.7.1
2 1 (function() {
3 1 module.exports = {
4 flatten: function(array) {
5 252 var output, _flatten;
6 252 output = [];
7 252 _flatten = function(array) {
8 489 return array.forEach(function(item) {
9 if (Array.isArray(item)) {
10 237 return _flatten(item);
11 } else {
12 445 return output.push(item);
13 }
14 });
15 };
16 252 _flatten(array);
17 252 return output;
18 },
19 toFlatString: function(array) {
20 110 return this.flatten(array).join("");
21 },
22 scan: function(string, regexp, globalMatch) {
23 305 var result, _scan;
24 if (globalMatch == null) {
25 305 globalMatch = false;
26 }
27 305 result = [];
28 305 _scan = function(s) {
29 402 var l, match;
30 402 match = regexp.exec(s);
31 if (match) {
32 if (match.length === 1) {
33 340 result.push(match[0]);
34 } else {
35 23 result.push(match.slice(1));
36 }
37 363 l = match[0].length;
38 if (globalMatch) {
39 0 l = 1;
40 }
41 if (match.index + l < s.length) {
42 97 return _scan(s.substring(match.index + l));
43 }
44 }
45 };
46 305 _scan(string);
47 305 return result;
48 }
49 };
50
51 }).call(this);
52
53 //# sourceMappingURL=helpers.map
54

lib/liquid/iterable.js

100%
54
54
0
Line Hits Source
1 // Generated by CoffeeScript 1.7.1
2 1 (function() {
3 1 var Iterable, IterableForArray, Promise, Range, isString,
4 __hasProp = {}.hasOwnProperty,
5 5 __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
6
7 1 Range = require("./range");
8
9 1 Promise = require("bluebird");
10
11 1 isString = function(input) {
12 6 return Object.prototype.toString.call(input) === "[object String]";
13 };
14
15 1 module.exports = Iterable = (function() {
16 function Iterable() {}
17
18 1 Iterable.prototype.first = function() {
19 5 return this.slice(0, 1).then(function(a) {
20 5 return a[0];
21 });
22 };
23
24 1 Iterable.prototype.map = function() {
25 3 var _ref;
26 3 return (_ref = this.toArray()).map.apply(_ref, arguments);
27 };
28
29 1 Iterable.prototype.sort = function() {
30 2 var args;
31 2 args = arguments;
32 2 return this.toArray().then(function(a) {
33 2 return a.sort.apply(a, args);
34 });
35 };
36
37 1 Iterable.prototype.toArray = function() {
38 14 return this.slice(0);
39 };
40
41 1 Iterable.prototype.slice = function() {
42 1 throw new Error("" + this.constructor.name + ".slice() not implemented");
43 };
44
45 1 Iterable.prototype.last = function() {
46 1 throw new Error("" + this.constructor.name + ".last() not implemented");
47 };
48
49 1 Iterable.cast = function(v) {
50 if (v instanceof Iterable) {
51 1 return v;
52 } else if (v instanceof Range) {
53 5 return new IterableForArray(v.toArray());
54 } else if (Array.isArray(v) || isString(v)) {
55 39 return new IterableForArray(v);
56 } else if (v != null) {
57 3 return new IterableForArray([v]);
58 } else {
59 1 return new IterableForArray([]);
60 }
61 };
62
63 1 return Iterable;
64
65 })();
66
67 1 IterableForArray = (function(_super) {
68 1 __extends(IterableForArray, _super);
69
70 function IterableForArray(array) {
71 48 this.array = array;
72 }
73
74 1 IterableForArray.prototype.slice = function() {
75 43 var _ref;
76 43 return Promise.cast((_ref = this.array).slice.apply(_ref, arguments));
77 };
78
79 1 IterableForArray.prototype.last = function() {
80 5 return Promise.cast(this.array[this.array.length - 1]);
81 };
82
83 1 return IterableForArray;
84
85 })(Iterable);
86
87 }).call(this);
88
89 //# sourceMappingURL=iterable.map
90

lib/liquid/range.js

100%
47
47
0
Line Hits Source
1 // Generated by CoffeeScript 1.7.1
2 1 (function() {
3 1 var Range;
4
5 1 module.exports = Range = (function() {
6 function Range(start, end, step) {
7 19 this.start = start;
8 19 this.end = end;
9 19 this.step = step != null ? step : 0;
10 if (this.step === 0) {
11 if (this.end < this.start) {
12 3 this.step = -1;
13 } else {
14 13 this.step = 1;
15 }
16 }
17 19 Object.seal(this);
18 }
19
20 1 Range.prototype.some = function(f) {
21 16 var current, end, step;
22 16 current = this.start;
23 16 end = this.end;
24 16 step = this.step;
25 if (step > 0) {
26 while (current < end) {
27 if (f(current)) {
28 1 return true;
29 }
30 2026 current += step;
31 }
32 } else {
33 while (current > end) {
34 if (f(current)) {
35 1 return true;
36 }
37 11 current += step;
38 }
39 }
40 14 return false;
41 };
42
43 1 Range.prototype.forEach = function(f) {
44 12 return this.some(function(e) {
45 2025 f(e);
46 2025 return false;
47 });
48 };
49
50 1 Range.prototype.toArray = function() {
51 12 var array;
52 12 array = [];
53 12 this.forEach(function(e) {
54 2025 return array.push(e);
55 });
56 12 return array;
57 };
58
59 1 return Range;
60
61 })();
62
63 1 Object.defineProperty(Range.prototype, "length", {
64 get: function() {
65 3 return Math.floor((this.end - this.start) / this.step);
66 }
67 });
68
69 }).call(this);
70
71 //# sourceMappingURL=range.map
72

lib/liquid/standard_filters.js

91.62011173184358%
179
164
15
Line Hits Source
1 // Generated by CoffeeScript 1.7.1
2 1 (function() {
3 1 var HTML_ESCAPE, HTML_ESCAPE_ONCE_REGEXP, HTML_ESCAPE_REGEXP, Iterable, Promise, isNumber, isString, strftime, toDate, toIterable, toNumber, toObjectString, toString;
4
5 1 strftime = require("strftime");
6
7 1 Promise = require("bluebird");
8
9 1 Iterable = require("./iterable");
10
11 1 toNumber = function(input) {
12 22 return Number(input);
13 };
14
15 1 toObjectString = Object.prototype.toString;
16
17 1 isString = function(input) {
18 356 return toObjectString.call(input) === "[object String]";
19 };
20
21 1 isNumber = function(input) {
22 203 return !Array.isArray(input) && (input - parseFloat(input)) >= 0;
23 };
24
25 1 toString = function(input) {
26 if (input == null) {
27 163 return "";
28 } else if (isString(input)) {
29 223 return input;
30 } else if (typeof input.toString === "function") {
31 132 return toString(input.toString());
32 } else {
33 1 return toObjectString.call(input);
34 }
35 };
36
37 1 toIterable = function(input) {
38 23 return Iterable.cast(input);
39 };
40
41 1 toDate = function(input) {
42 if (input == null) {
43 66 return;
44 }
45 if (input instanceof Date) {
46 3 return input;
47 }
48 if (isNumber(input)) {
49 34 input = parseInt(input);
50 } else {
51 169 input = toString(input);
52 if (input.length === 0) {
53 32 return;
54 }
55 137 input = Date.parse(input);
56 }
57 if (input != null) {
58 171 return new Date(input);
59 }
60 };
61
62 1 HTML_ESCAPE = function(chr) {
63 switch (chr) {
64 case "&":
65 0 return '&';
66 case ">":
67 2 return '>';
68 case "<":
69 2 return '<';
70 case '"':
71 0 return '"';
72 case "'":
73 0 return ''';
74 }
75 };
76
77 1 HTML_ESCAPE_ONCE_REGEXP = /["><']|&(?!([a-zA-Z]+|(#\d+));)/g;
78
79 1 HTML_ESCAPE_REGEXP = /([&><"'])/g;
80
81 1 module.exports = {
82 size: function(input) {
83 8 var _ref;
84 8 return (_ref = input != null ? input.length : void 0) != null ? _ref : 0;
85 },
86 downcase: function(input) {
87 2 return toString(input).toLowerCase();
88 },
89 upcase: function(input) {
90 5 return toString(input).toUpperCase();
91 },
92 append: function(input, suffix) {
93 1 return toString(input) + toString(suffix);
94 },
95 prepend: function(input, prefix) {
96 1 return toString(prefix) + toString(input);
97 },
98 empty: function(input) {
99 if (!input) {
100 0 return true;
101 }
102 if (input.length == null) {
103 0 return false;
104 }
105 0 return true;
106 },
107 capitalize: function(input) {
108 1 return toString(input).replace(/^([a-z])/, function(m, chr) {
109 1 return chr.toUpperCase();
110 });
111 },
112 sort: function(input, property) {
113 if (property == null) {
114 2 return toIterable(input).sort();
115 }
116 2 return toIterable(input).map(function(item) {
117 6 return Promise.cast(item != null ? item[property] : void 0).then(function(key) {
118 6 return {
119 key: key,
120 item: item
121 };
122 });
123 }).then(function(array) {
124 2 return array.sort(function(a, b) {
125 5 var _ref, _ref1;
126 5 return (_ref = a.key > b.key) != null ? _ref : {
127 1: (_ref1 = a.key === b.key) != null ? _ref1 : {
128 0: -1
129 }
130 };
131 }).map(function(a) {
132 6 return a.item;
133 });
134 });
135 },
136 map: function(input, property) {
137 if (property == null) {
138 1 return input;
139 }
140 1 return toIterable(input).map(function(e) {
141 3 return e != null ? e[property] : void 0;
142 });
143 },
144 escape: function(input) {
145 1 return toString(input).replace(HTML_ESCAPE_REGEXP, HTML_ESCAPE);
146 },
147 escape_once: function(input) {
148 1 return toString(input).replace(HTML_ESCAPE_ONCE_REGEXP, HTML_ESCAPE);
149 },
150 strip_html: function(input) {
151 5 return toString(input).replace(//g, "").replace(//g, "").replace(//g, "").replace(/<[^>]*?>/g, "");
152 },
153 strip_newlines: function(input) {
154 2 return toString(input).replace(/\r?\n/g, "");
155 },
156 newline_to_br: function(input) {
157 1 return toString(input).replace(/\n/g, "
\n");
158 },
159 replace: function(input, string, replacement) {
160 if (replacement == null) {
161 1 replacement = "";
162 }
163 2 return toString(input).replace(new RegExp(string, 'g'), replacement);
164 },
165 replace_first: function(input, string, replacement) {
166 if (replacement == null) {
167 1 replacement = "";
168 }
169 2 return toString(input).replace(string, replacement);
170 },
171 remove: function(input, string) {
172 1 return this.replace(input, string);
173 },
174 remove_first: function(input, string) {
175 1 return this.replace_first(input, string);
176 },
177 truncate: function(input, length, truncateString) {
178 5 var l;
179 if (length == null) {
180 2 length = 50;
181 }
182 if (truncateString == null) {
183 3 truncateString = '...';
184 }
185 5 input = toString(input);
186 5 truncateString = toString(truncateString);
187 5 length = toNumber(length);
188 5 l = length - truncateString.length;
189 if (l < 0) {
190 1 l = 0;
191 }
192 if (input.length > length) {
193 4 return input.slice(0, l) + truncateString;
194 } else {
195 1 return input;
196 }
197 },
198 truncatewords: function(input, words, truncateString) {
199 5 var wordlist;
200 if (words == null) {
201 1 words = 15;
202 }
203 if (truncateString == null) {
204 4 truncateString = '...';
205 }
206 5 input = toString(input);
207 5 wordlist = input.split(" ");
208 5 words = Math.max(1, toNumber(words));
209 if (wordlist.length > words) {
210 4 return wordlist.slice(0, words).join(" ") + truncateString;
211 } else {
212 1 return input;
213 }
214 },
215 split: function(input, pattern) {
216 3 input = toString(input);
217 if (!input) {
218 1 return;
219 }
220 2 return input.split(pattern);
221 },
222 flatten: function(input) {
223 8 return toIterable(input).toArray().then(function(a) {
224 8 return Liquid.Helpers.flatten(a);
225 });
226 },
227 join: function(input, glue) {
228 if (glue == null) {
229 3 glue = ' ';
230 }
231 8 return this.flatten(input).then(function(a) {
232 8 return a.join(glue);
233 });
234 },
235 first: function(input) {
236 5 return toIterable(input).first();
237 },
238 last: function(input) {
239 5 return toIterable(input).last();
240 },
241 plus: function(input, operand) {
242 1 return toNumber(input) + toNumber(operand);
243 },
244 minus: function(input, operand) {
245 1 return toNumber(input) - toNumber(operand);
246 },
247 times: function(input, operand) {
248 1 return toNumber(input) * toNumber(operand);
249 },
250 dividedBy: function(input, operand) {
251 2 return toNumber(input) / toNumber(operand);
252 },
253 divided_by: function(input, operand) {
254 1 return this.dividedBy(input, operand);
255 },
256 modulo: function(input, operand) {
257 1 return toNumber(input) % toNumber(operand);
258 },
259 date: function(input, format) {
260 272 input = toDate(input);
261 if (input == null) {
262 98 return "";
263 } else if (toString(format).length === 0) {
264 164 return input.toUTCString();
265 } else {
266 10 return strftime(format, input);
267 }
268 }
269 };
270
271 }).call(this);
272
273 //# sourceMappingURL=standard_filters.map
274

lib/liquid/tag.js

92.85714285714286%
28
26
2
Line Hits Source
1 // Generated by CoffeeScript 1.7.1
2 1 (function() {
3 1 var Promise, Tag,
4 __slice = [].slice;
5
6 1 Promise = require("bluebird");
7
8 1 module.exports = Tag = (function() {
9 function Tag(template, tagName, markup) {
10 93 this.template = template;
11 93 this.tagName = tagName;
12 93 this.markup = markup;
13 }
14
15 1 Tag.prototype.parseWithCallbacks = function() {
16 204 var args, parse;
17 204 args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
18 if (this.afterParse) {
19 196 parse = (function(_this) {
20 196 return function() {
21 196 return _this.parse.apply(_this, args).then(function() {
22 186 return _this.afterParse.apply(_this, args);
23 });
24 };
25 })(this);
26 } else {
27 8 parse = (function(_this) {
28 8 return function() {
29 8 return _this.parse.apply(_this, args);
30 };
31 })(this);
32 }
33 if (this.beforeParse) {
34 196 return Promise.cast(this.beforeParse.apply(this, args)).then(parse);
35 } else {
36 8 return parse();
37 }
38 };
39
40 1 Tag.prototype.parse = function() {};
41
42 1 Tag.prototype.name = function() {
43 0 return this.constructor.name.toLowerCase();
44 };
45
46 1 Tag.prototype.render = function() {
47 4 return "";
48 };
49
50 1 return Tag;
51
52 })();
53
54 }).call(this);
55
56 //# sourceMappingURL=tag.map
57

lib/liquid/tags/assign.js

95.83333333333334%
24
23
1
Line Hits Source
1 // Generated by CoffeeScript 1.7.1
2 1 (function() {
3 1 var Assign, Liquid, Promise,
4 __hasProp = {}.hasOwnProperty,
5 5 __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
6
7 1 Liquid = require("../../liquid");
8
9 1 Promise = require("bluebird");
10
11 1 module.exports = Assign = (function(_super) {
12 1 var Syntax, SyntaxHelp;
13
14 1 __extends(Assign, _super);
15
16 1 SyntaxHelp = "Syntax Error in 'assign' - Valid syntax: assign [var] = [source]";
17
18 1 Syntax = RegExp("((?:" + Liquid.VariableSignature.source + ")+)\\s*=\\s*((?:" + Liquid.QuotedFragment.source + "))");
19
20 function Assign(template, tagName, markup) {
21 4 var match;
22 if (match = Syntax.exec(markup)) {
23 4 this.to = match[1];
24 4 this.from = match[2];
25 } else {
26 0 throw new Liquid.SyntaxError(SyntaxHelp);
27 }
28 4 Assign.__super__.constructor.apply(this, arguments);
29 }
30
31 1 Assign.prototype.render = function(context) {
32 4 context.lastScope()[this.to] = context.get(this.from);
33 4 return Assign.__super__.render.call(this, context);
34 };
35
36 1 return Assign;
37
38 })(Liquid.Tag);
39
40 }).call(this);
41
42 //# sourceMappingURL=assign.map
43

lib/liquid/tags/capture.js

95.45454545454545%
22
21
1
Line Hits Source
1 // Generated by CoffeeScript 1.7.1
2 1 (function() {
3 1 var Capture, Liquid,
4 __hasProp = {}.hasOwnProperty,
5 5 __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
6
7 1 Liquid = require("../../liquid");
8
9 1 module.exports = Capture = (function(_super) {
10 1 var Syntax, SyntaxHelp;
11
12 1 __extends(Capture, _super);
13
14 1 Syntax = /(\w+)/;
15
16 1 SyntaxHelp = "Syntax Error in 'capture' - Valid syntax: capture [var]";
17
18 function Capture(template, tagName, markup) {
19 6 var match;
20 6 match = Syntax.exec(markup);
21 if (match) {
22 6 this.to = match[1];
23 } else {
24 0 throw new Liquid.SyntaxError(SyntaxHelp);
25 }
26 6 Capture.__super__.constructor.apply(this, arguments);
27 }
28
29 1 Capture.prototype.render = function(context) {
30 2 return Capture.__super__.render.apply(this, arguments).then((function(_this) {
31 2 return function(chunks) {
32 2 var output;
33 2 output = Liquid.Helpers.toFlatString(chunks);
34 2 context.lastScope()[_this.to] = output;
35 2 return "";
36 };
37 })(this));
38 };
39
40 1 return Capture;
41
42 })(Liquid.Block);
43
44 }).call(this);
45
46 //# sourceMappingURL=capture.map
47

lib/liquid/tags/comment.js

100%
10
10
0
Line Hits Source
1 // Generated by CoffeeScript 1.7.1
2 1 (function() {
3 1 var Comment, Raw,
4 __hasProp = {}.hasOwnProperty,
5 5 __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
6
7 1 Raw = require("./raw");
8
9 1 module.exports = Comment = (function(_super) {
10 1 __extends(Comment, _super);
11
12 function Comment() {
13 1 return Comment.__super__.constructor.apply(this, arguments);
14 }
15
16 1 Comment.prototype.render = function() {
17 1 return "";
18 };
19
20 1 return Comment;
21
22 })(Raw);
23
24 }).call(this);
25
26 //# sourceMappingURL=comment.map
27

lib/liquid/tags/decrement.js

100%
18
18
0
Line Hits Source
1 // Generated by CoffeeScript 1.7.1
2 1 (function() {
3 1 var Decrement, Liquid,
4 __hasProp = {}.hasOwnProperty,
5 5 __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
6
7 1 Liquid = require("../../liquid");
8
9 1 module.exports = Decrement = (function(_super) {
10 1 __extends(Decrement, _super);
11
12 function Decrement(template, tagName, markup) {
13 2 this.variable = markup.trim();
14 2 Decrement.__super__.constructor.apply(this, arguments);
15 }
16
17 1 Decrement.prototype.render = function(context) {
18 2 var value, _base, _name;
19 2 value = (_base = context.environments[0])[_name = this.variable] || (_base[_name] = 0);
20 2 value = value - 1;
21 2 context.environments[0][this.variable] = value;
22 2 return value.toString();
23 };
24
25 1 return Decrement;
26
27 })(Liquid.Tag);
28
29 }).call(this);
30
31 //# sourceMappingURL=decrement.map
32

lib/liquid/tags/for.js

93.75%
96
90
6
Line Hits Source
1 // Generated by CoffeeScript 1.7.1
2 1 (function() {
3 1 var For, Iterable, Liquid, Promise,
4 __hasProp = {}.hasOwnProperty,
5 5 __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
6
7 1 Liquid = require("../../liquid");
8
9 1 Promise = require("bluebird");
10
11 1 Iterable = require("../iterable");
12
13 1 module.exports = For = (function(_super) {
14 1 var Syntax, SyntaxHelp;
15
16 1 __extends(For, _super);
17
18 1 SyntaxHelp = "Syntax Error in 'for loop' - Valid syntax: for [item] in [collection]";
19
20 1 Syntax = RegExp("(\\w+)\\s+in\\s+((?:" + Liquid.QuotedFragment.source + ")+)\\s*(reversed)?");
21
22 function For(template, tagName, markup) {
23 28 var match;
24 28 match = Syntax.exec(markup);
25 if (match) {
26 28 this.variableName = match[1];
27 28 this.collectionName = match[2];
28 28 this.registerName = "" + match[1] + "=" + match[2];
29 28 this.reversed = match[3];
30 28 this.attributes = {};
31 28 Liquid.Helpers.scan(markup, Liquid.TagAttributes).forEach((function(_this) {
32 28 return function(attr) {
33 2 return _this.attributes[attr[0]] = attr[1];
34 };
35 })(this));
36 } else {
37 0 throw new Liquid.SyntaxError(SyntaxHelp);
38 }
39 28 this.nodelist = this.forBlock = [];
40 28 For.__super__.constructor.apply(this, arguments);
41 }
42
43 1 For.prototype.unknownTag = function(tag, markup) {
44 if (tag !== "else") {
45 0 return For.__super__.unknownTag.apply(this, arguments);
46 }
47 1 return this.nodelist = this.elseBlock = [];
48 };
49
50 1 For.prototype.render = function(context) {
51 25 var _base;
52 25 (_base = context.registers)["for"] || (_base["for"] = {});
53 25 return Promise.cast(context.get(this.collectionName)).then((function(_this) {
54 25 return function(collection) {
55 25 var from, limit, to;
56 if (!(collection && collection.forEach)) {
57 1 return _this.renderElse(context);
58 }
59 24 from = _this.attributes.offset === "continue" ? Number(context.registers["for"][_this.registerName]) || 0 : Number(_this.attributes.offset) || 0;
60 24 limit = _this.attributes.limit;
61 24 to = limit ? Number(limit) + from : null;
62 24 return _this.sliceCollection(collection, from, to).then(function(segment) {
63 24 var length;
64 if (segment.length === 0) {
65 1 return _this.renderElse(context);
66 }
67 if (_this.reversed) {
68 1 segment.reverse();
69 }
70 23 length = segment.length;
71 23 context.registers["for"][_this.registerName] = from + segment.length;
72 23 return context.stack(function() {
73 23 return Promise.reduce(segment, function(output, item, index) {
74 78 context.set(_this.variableName, item);
75 78 context.set("forloop", {
76 name: _this.registerName,
77 length: length,
78 index: index + 1,
79 index0: index,
80 rindex: length - index,
81 rindex0: length - index - 1,
82 first: index === 0,
83 last: index === length - 1
84 });
85 78 return Promise["try"](function() {
86 78 return _this.renderAll(_this.forBlock, context);
87 }).then(function(rendered) {
88 78 output.push(rendered);
89 78 return output;
90 })["catch"](function(e) {
91 0 output.push(context.handleError(e));
92 0 return output;
93 });
94 }, []);
95 });
96 });
97 };
98 })(this));
99 };
100
101 1 For.prototype.sliceCollection = function(collection, from, to) {
102 24 var args, _ref;
103 24 args = [from];
104 if (to != null) {
105 1 args.push(to);
106 }
107 24 return (_ref = Iterable.cast(collection)).slice.apply(_ref, args);
108 };
109
110 1 For.prototype.renderElse = function(context) {
111 if (this.elseBlock) {
112 1 return this.renderAll(this.elseBlock, context);
113 } else {
114 1 return "";
115 }
116 };
117
118 1 return For;
119
120 })(Liquid.Block);
121
122 }).call(this);
123
124 //# sourceMappingURL=for.map
125

lib/liquid/tags/if.js

93.15068493150685%
73
68
5
Line Hits Source
1 // Generated by CoffeeScript 1.7.1
2 1 (function() {
3 1 var If, Liquid, Promise,
4 __hasProp = {}.hasOwnProperty,
5 5 __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
6
7 1 Liquid = require("../../liquid");
8
9 1 Promise = require("bluebird");
10
11 1 module.exports = If = (function(_super) {
12 1 var ExpressionsAndOperators, Syntax, SyntaxHelp;
13
14 1 __extends(If, _super);
15
16 1 SyntaxHelp = "Syntax Error in tag 'if' - Valid syntax: if [expression]";
17
18 1 Syntax = RegExp("(" + Liquid.QuotedFragment.source + ")\\s*([=!<>a-z_]+)?\\s*(" + Liquid.QuotedFragment.source + ")?");
19
20 1 ExpressionsAndOperators = RegExp("(?:\\b(?:\\s?and\\s?|\\s?or\\s?)\\b|(?:\\s*(?!\\b(?:\\s?and\\s?|\\s?or\\s?)\\b)(?:" + Liquid.QuotedFragment.source + "|\\S+)\\s*)+)");
21
22 function If(template, tagName, markup) {
23 46 this.blocks = [];
24 46 this.pushBlock('if', markup);
25 46 If.__super__.constructor.apply(this, arguments);
26 }
27
28 1 If.prototype.unknownTag = function(tag, markup) {
29 if (["elsif", "else"].indexOf(tag) >= 0) {
30 5 return this.pushBlock(tag, markup);
31 } else {
32 0 return If.__super__.unknownTag.apply(this, arguments);
33 }
34 };
35
36 1 If.prototype.render = function(context) {
37 50 return context.stack((function(_this) {
38 50 return function() {
39 50 return Promise.reduce(_this.blocks, function(chosenBlock, block) {
40 if (chosenBlock != null) {
41 3 return chosenBlock;
42 }
43 52 return Promise["try"](function() {
44 52 return block.evaluate(context);
45 }).then(function(ok) {
46 if (block.negate) {
47 3 ok = !ok;
48 }
49 if (ok) {
50 36 return block;
51 }
52 });
53 }, null).then(function(block) {
54 if (block != null) {
55 36 return _this.renderAll(block.attachment, context);
56 } else {
57 13 return "";
58 }
59 });
60 };
61 })(this));
62 };
63
64 1 If.prototype.pushBlock = function(tag, markup) {
65 51 var block, condition, expressions, match, newCondition, operator;
66 51 block = (function() {
67 if (tag === "else") {
68 5 return new Liquid.ElseCondition();
69 } else {
70 46 expressions = Liquid.Helpers.scan(markup, ExpressionsAndOperators);
71 46 expressions = expressions.reverse();
72 46 match = Syntax.exec(expressions.shift());
73 if (!match) {
74 0 throw new Liquid.SyntaxError(SyntaxHelp);
75 }
76 46 condition = (function(func, args, ctor) {
77 46 ctor.prototype = func.prototype;
78 46 var child = new ctor, result = func.apply(child, args);
79 46 return Object(result) === result ? result : child;
80 })(Liquid.Condition, match.slice(1, 4), function(){});
81 while (expressions.length > 0) {
82 10 operator = String(expressions.shift()).trim();
83 10 match = Syntax.exec(expressions.shift());
84 if (!match) {
85 0 throw new SyntaxError(SyntaxHelp);
86 }
87 10 newCondition = (function(func, args, ctor) {
88 10 ctor.prototype = func.prototype;
89 10 var child = new ctor, result = func.apply(child, args);
90 10 return Object(result) === result ? result : child;
91 })(Liquid.Condition, match.slice(1, 4), function(){});
92 10 newCondition[operator].call(newCondition, condition);
93 10 condition = newCondition;
94 }
95 46 return condition;
96 }
97 })();
98 51 this.blocks.push(block);
99 51 return this.nodelist = block.attach([]);
100 };
101
102 1 return If;
103
104 })(Liquid.Block);
105
106 }).call(this);
107
108 //# sourceMappingURL=if.map
109

lib/liquid/tags/ifchanged.js

100%
20
20
0
Line Hits Source
1 // Generated by CoffeeScript 1.7.1
2 1 (function() {
3 1 var IfChanged, Liquid, Promise,
4 __hasProp = {}.hasOwnProperty,
5 5 __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
6
7 1 Liquid = require("../../liquid");
8
9 1 Promise = require("bluebird");
10
11 1 module.exports = IfChanged = (function(_super) {
12 1 __extends(IfChanged, _super);
13
14 function IfChanged() {
15 3 return IfChanged.__super__.constructor.apply(this, arguments);
16 }
17
18 1 IfChanged.prototype.render = function(context) {
19 13 return context.stack((function(_this) {
20 13 return function() {
21 13 var rendered;
22 13 rendered = _this.renderAll(_this.nodelist, context);
23 13 return Promise.cast(rendered).then(function(output) {
24 13 output = Liquid.Helpers.toFlatString(output);
25 if (output !== context.registers.ifchanged) {
26 6 return context.registers.ifchanged = output;
27 } else {
28 7 return "";
29 }
30 });
31 };
32 })(this));
33 };
34
35 1 return IfChanged;
36
37 })(Liquid.Block);
38
39 }).call(this);
40
41 //# sourceMappingURL=ifchanged.map
42

lib/liquid/tags/increment.js

100%
18
18
0
Line Hits Source
1 // Generated by CoffeeScript 1.7.1
2 1 (function() {
3 1 var Increment, Liquid,
4 __hasProp = {}.hasOwnProperty,
5 5 __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
6
7 1 Liquid = require("../../liquid");
8
9 1 module.exports = Increment = (function(_super) {
10 1 __extends(Increment, _super);
11
12 function Increment(template, tagName, markup) {
13 2 this.variable = markup.trim();
14 2 Increment.__super__.constructor.apply(this, arguments);
15 }
16
17 1 Increment.prototype.render = function(context) {
18 2 var value, _base, _name;
19 2 value = (_base = context.environments[0])[_name = this.variable] != null ? _base[_name] : _base[_name] = 0;
20 2 context.environments[0][this.variable] = value + 1;
21 2 return String(value);
22 };
23
24 1 return Increment;
25
26 })(Liquid.Tag);
27
28 }).call(this);
29
30 //# sourceMappingURL=increment.map
31

lib/liquid/tags/raw.js

96.29629629629629%
27
26
1
Line Hits Source
1 // Generated by CoffeeScript 1.7.1
2 1 (function() {
3 1 var Liquid, Promise, Raw,
4 __hasProp = {}.hasOwnProperty,
5 5 __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
6
7 1 Liquid = require("../../liquid");
8
9 1 Promise = require("bluebird");
10
11 1 module.exports = Raw = (function(_super) {
12 1 __extends(Raw, _super);
13
14 function Raw() {
15 2 return Raw.__super__.constructor.apply(this, arguments);
16 }
17
18 1 Raw.prototype.parse = function(tokens) {
19 6 return Promise["try"]((function(_this) {
20 6 return function() {
21 6 var match, token;
22 if (tokens.length === 0 || _this.ended) {
23 0 return Promise.cast();
24 }
25 6 token = tokens.shift();
26 6 match = Liquid.Block.FullToken.exec(token.value);
27 if ((match != null ? match[1] : void 0) === _this.blockDelimiter()) {
28 2 return _this.endTag();
29 }
30 4 _this.nodelist.push(token.value);
31 4 return _this.parse(tokens);
32 };
33 })(this));
34 };
35
36 1 return Raw;
37
38 })(Liquid.Block);
39
40 }).call(this);
41
42 //# sourceMappingURL=raw.map
43

lib/liquid/tags/unless.js

100%
12
12
0
Line Hits Source
1 // Generated by CoffeeScript 1.7.1
2 1 (function() {
3 1 var Liquid, Unless,
4 __hasProp = {}.hasOwnProperty,
5 5 __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
6
7 1 Liquid = require("../../liquid");
8
9 1 module.exports = Unless = (function(_super) {
10 1 __extends(Unless, _super);
11
12 function Unless() {
13 3 return Unless.__super__.constructor.apply(this, arguments);
14 }
15
16 1 Unless.prototype.parse = function() {
17 11 return Unless.__super__.parse.apply(this, arguments).then((function(_this) {
18 11 return function() {
19 11 return _this.blocks[0].negate = true;
20 };
21 })(this));
22 };
23
24 1 return Unless;
25
26 })(Liquid.If);
27
28 }).call(this);
29
30 //# sourceMappingURL=unless.map
31

lib/liquid/template.js

98.85057471264368%
87
86
1
Line Hits Source
1 // Generated by CoffeeScript 1.7.1
2 1 (function() {
3 1 var Liquid, Promise,
4 __slice = [].slice,
5 __hasProp = {}.hasOwnProperty;
6
7 1 Liquid = require("../liquid");
8
9 1 Promise = require("bluebird");
10
11 1 module.exports = Liquid.Template = (function() {
12 function Template() {
13 112 this.registers = {};
14 112 this.assigns = {};
15 112 this.instanceAssigns = {};
16 112 this.tags = {};
17 112 this.errors = [];
18 112 this.rethrowErrors = true;
19 }
20
21 1 Template.prototype.parse = function(engine, source) {
22 111 this.engine = engine;
23 if (source == null) {
24 0 source = "";
25 }
26 111 return Promise["try"]((function(_this) {
27 111 return function() {
28 111 var tokens;
29 111 tokens = _this._tokenize(source);
30 111 _this.tags = _this.engine.tags;
31 111 _this.root = new Liquid.Document(_this);
32 111 return _this.root.parseWithCallbacks(tokens).then(function() {
33 103 return _this;
34 });
35 };
36 })(this));
37 };
38
39 1 Template.prototype.render = function() {
40 97 var args;
41 97 args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
42 97 return Promise["try"]((function(_this) {
43 97 return function() {
44 97 return _this._render.apply(_this, args);
45 };
46 })(this));
47 };
48
49 1 Template.prototype._render = function(assigns, options) {
50 97 var context, k, v, _ref;
51 if (this.root == null) {
52 1 throw new Error("No document root. Did you parse the document yet?");
53 }
54 96 context = (function() {
55 if (assigns instanceof Liquid.Context) {
56 1 return assigns;
57 } else if (assigns instanceof Object) {
58 77 assigns = [assigns, this.assigns];
59 77 return new Liquid.Context(this.engine, assigns, this.instanceAssigns, this.registers, this.rethrowErrors);
60 } else if (assigns == null) {
61 17 return new Liquid.Context(this.engine, this.assigns, this.instanceAssigns, this.registers, this.rethrowErrors);
62 } else {
63 1 throw new Error("Expected Object or Liquid::Context as parameter, but was " + (typeof assigns) + ".");
64 }
65 }).call(this);
66 if (options != null ? options.registers : void 0) {
67 1 _ref = options.registers;
68 for (k in _ref) {
69 if (!__hasProp.call(_ref, k)) continue;
70 1 v = _ref[k];
71 1 this.registers[k] = v;
72 }
73 }
74 if (options != null ? options.filters : void 0) {
75 1 context.registerFilters.apply(context, options.filters);
76 }
77 95 return this.root.render(context).then(function(chunks) {
78 95 return Liquid.Helpers.toFlatString(chunks);
79 })["finally"]((function(_this) {
80 95 return function() {
81 95 return _this.errors = context.errors;
82 };
83 })(this));
84 };
85
86 1 Template.prototype._tokenize = function(source) {
87 111 var col, line, tokens;
88 111 source = String(source);
89 if (source.length === 0) {
90 1 return [];
91 }
92 110 tokens = source.split(Liquid.TemplateParser);
93 110 line = 1;
94 110 col = 1;
95 110 return tokens.filter(function(token) {
96 598 return token.length > 0;
97 }).map(function(value) {
98 321 var lastIndex, linebreaks, result;
99 321 result = {
100 value: value,
101 col: col,
102 line: line
103 };
104 321 lastIndex = value.lastIndexOf("\n");
105 if (lastIndex < 0) {
106 317 col += value.length;
107 } else {
108 4 linebreaks = value.split("\n").length - 1;
109 4 line += linebreaks;
110 4 col = value.length - lastIndex;
111 }
112 321 return result;
113 });
114 };
115
116 1 return Template;
117
118 })();
119
120 }).call(this);
121
122 //# sourceMappingURL=template.map
123

lib/liquid/variable.js

98.82352941176471%
85
84
1
Line Hits Source
1 // Generated by CoffeeScript 1.7.1
2 1 (function() {
3 1 var Liquid, Promise, Variable,
4 __slice = [].slice;
5
6 1 Liquid = require("../liquid");
7
8 1 Promise = require("bluebird");
9
10 1 module.exports = Variable = (function() {
11 1 var FilterArgParser, FilterListFragment, VariableNameFragment;
12
13 1 Variable.FilterParser = RegExp("(?:" + Liquid.FilterSeparator.source + "|(?:\\s*(?!(?:" + Liquid.FilterSeparator.source + "))(?:" + Liquid.QuotedFragment.source + "|\\S+)\\s*)+)");
14
15 1 VariableNameFragment = RegExp("\\s*(" + Liquid.QuotedFragment.source + ")(.*)");
16
17 1 FilterListFragment = RegExp("" + Liquid.FilterSeparator.source + "\\s*(.*)");
18
19 1 FilterArgParser = RegExp("(?:" + Liquid.FilterArgumentSeparator.source + "|" + Liquid.ArgumentSeparator.source + ")\\s*(" + Liquid.QuotedFragment.source + ")");
20
21 function Variable(markup) {
22 65 var filters, match;
23 65 this.markup = markup;
24 65 this.name = null;
25 65 this.filters = [];
26 65 match = VariableNameFragment.exec(this.markup);
27 if (!match) {
28 1 return;
29 }
30 64 this.name = match[1];
31 64 match = FilterListFragment.exec(match[2]);
32 if (!match) {
33 46 return;
34 }
35 18 filters = Liquid.Helpers.scan(match[1], Liquid.Variable.FilterParser);
36 18 filters.forEach((function(_this) {
37 18 return function(filter) {
38 24 var filterArgs, filterName;
39 24 match = /\s*(\w+)/.exec(filter);
40 if (!match) {
41 3 return;
42 }
43 21 filterName = match[1];
44 21 filterArgs = Liquid.Helpers.scan(filter, FilterArgParser);
45 21 filterArgs = Liquid.Helpers.flatten(filterArgs);
46 21 return _this.filters.push([filterName, filterArgs]);
47 };
48 })(this));
49 }
50
51 1 Variable.prototype.render = function(context) {
52 103 var reducer;
53 if (this.name == null) {
54 1 return '';
55 }
56 102 reducer = (function(_this) {
57 102 return function(output, filter) {
58 8 var filterArgs;
59 8 filterArgs = filter[1].map(function(a) {
60 5 return context.get(a);
61 });
62 8 return Promise.join.apply(Promise, [output].concat(__slice.call(filterArgs))).spread(function() {
63 8 var e, filterArgs, output;
64 8 output = arguments[0], filterArgs = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
65 try {
66 8 return context.invoke.apply(context, [filter[0], output].concat(__slice.call(filterArgs)));
67 } catch (_error) {
68 1 e = _error;
69 if (!(e instanceof Liquid.FilterNotFound)) {
70 0 throw e;
71 }
72 1 throw new Liquid.FilterNotFound("Error - filter '" + filter[0] + "' in '" + _this.markup + "' could not be found.");
73 }
74 });
75 };
76 })(this);
77 102 return Promise.cast(context.get(this.name)).then((function(_this) {
78 102 return function(value) {
79 102 return Promise.reduce(_this.filters, reducer, value).then(function(value) {
80 if (value instanceof Liquid.Drop) {
81 1 value.context = context;
82 1 return value.toString();
83 } else {
84 100 return value;
85 }
86 }, function(e) {
87 1 return context.handleError(e);
88 });
89 };
90 })(this));
91 };
92
93 1 return Variable;
94
95 })();
96
97 }).call(this);
98
99 //# sourceMappingURL=variable.map
100