mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-16 12:50:38 -07:00
chore(release): 7.2.1 [skip ci]
## [7.2.1](https://github.com/harttle/liquidjs/compare/v7.2.0...v7.2.1) (2019-02-22)
### Bug Fixes
* default length for truncate and truncatewords ([56c7992](https://github.com/harttle/liquidjs/commit/56c7992))
This commit is contained in:
@@ -1,3 +1,10 @@
|
||||
## [7.2.1](https://github.com/harttle/liquidjs/compare/v7.2.0...v7.2.1) (2019-02-22)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* default length for truncate and truncatewords ([56c7992](https://github.com/harttle/liquidjs/commit/56c7992))
|
||||
|
||||
# [7.2.0](https://github.com/harttle/liquidjs/compare/v7.1.0...v7.2.0) (2019-02-20)
|
||||
|
||||
|
||||
|
||||
Vendored
+12
-9
@@ -1,12 +1,15 @@
|
||||
declare const _default: {
|
||||
'join': (v: any, arg: any) => any;
|
||||
'last': (v: any) => any;
|
||||
'first': (v: any) => any;
|
||||
'map': (arr: any, arg: any) => any;
|
||||
'reverse': (v: any) => any;
|
||||
'sort': (v: any, arg: any) => any;
|
||||
'size': (v: any) => any;
|
||||
'slice': (v: any, begin: any, length: any) => any;
|
||||
'uniq': (arr: any) => any;
|
||||
'join': (v: any[], arg: string) => string;
|
||||
'last': <T>(v: T[]) => T;
|
||||
'first': <T>(v: T[]) => T;
|
||||
'map': <T1, T2>(arr: {
|
||||
[key: string]: T1;
|
||||
}[], arg: string) => T1[];
|
||||
'reverse': (v: any[]) => any[];
|
||||
'sort': <T>(v: T[], arg: (lhs: T, rhs: T) => number) => T[];
|
||||
'size': (v: string | any[]) => number;
|
||||
'concat': <T1, T2>(v: T1[], arg: T2 | T2[]) => (T1 | T2)[];
|
||||
'slice': <T>(v: T[], begin: number, length: number) => T[];
|
||||
'uniq': <T>(arr: T[]) => T[];
|
||||
};
|
||||
export default _default;
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
declare const _default: {
|
||||
'date': (v: any, arg: any) => any;
|
||||
'date': (v: string | Date, arg: string) => string | Date;
|
||||
};
|
||||
export default _default;
|
||||
|
||||
Vendored
+4
-4
@@ -1,8 +1,8 @@
|
||||
declare function escape(str: any): string;
|
||||
declare function escape(str: string): string;
|
||||
declare const _default: {
|
||||
'escape': typeof escape;
|
||||
'escape_once': (str: any) => string;
|
||||
'newline_to_br': (v: any) => any;
|
||||
'strip_html': (v: any) => string;
|
||||
'escape_once': (str: string) => string;
|
||||
'newline_to_br': (v: string) => string;
|
||||
'strip_html': (v: string) => string;
|
||||
};
|
||||
export default _default;
|
||||
|
||||
Vendored
+29
-43
@@ -1,46 +1,32 @@
|
||||
declare const _default: {
|
||||
'join': (v: any, arg: any) => any;
|
||||
'last': (v: any) => any;
|
||||
'first': (v: any) => any;
|
||||
'map': (arr: any, arg: any) => any;
|
||||
'reverse': (v: any) => any;
|
||||
'sort': (v: any, arg: any) => any;
|
||||
'size': (v: any) => any;
|
||||
'slice': (v: any, begin: any, length: any) => any;
|
||||
'uniq': (arr: any) => any;
|
||||
'default': (v: any, arg: any) => any;
|
||||
'date': (v: any, arg: any) => any;
|
||||
'url_decode': (x: any) => any;
|
||||
'url_encode': (x: any) => any;
|
||||
'abs': (v: any) => number;
|
||||
'ceil': (v: any) => number;
|
||||
'divided_by': (v: any, arg: any) => number;
|
||||
'floor': (v: any) => number;
|
||||
'minus': (l: any, r: any) => any;
|
||||
'modulo': (l: any, r: any) => any;
|
||||
'round': (v: any, arg: any) => number;
|
||||
'plus': (l: any, r: any) => any;
|
||||
'times': (v: any, arg: any) => number;
|
||||
'append': (v: any, arg: any) => any;
|
||||
'prepend': (v: any, arg: any) => any;
|
||||
'capitalize': (str: any) => string;
|
||||
'concat': (v: any, arg: any) => any;
|
||||
'lstrip': (v: any) => string;
|
||||
'downcase': (v: any) => any;
|
||||
'upcase': (str: any) => string;
|
||||
'remove': (v: any, arg: any) => any;
|
||||
'remove_first': (v: any, l: any) => any;
|
||||
'replace': (v: any, pattern: any, replacement: any) => string;
|
||||
'replace_first': (v: any, arg1: any, arg2: any) => string;
|
||||
'rstrip': (str: any) => string;
|
||||
'split': (v: any, arg: any) => string[];
|
||||
'strip': (v: any) => string;
|
||||
'strip_newlines': (v: any) => string;
|
||||
'truncate': (v: any, l: any, o: any) => any;
|
||||
'truncatewords': (v: any, l: any, o: any) => any;
|
||||
'escape': (str: any) => string;
|
||||
'escape_once': (str: any) => string;
|
||||
'newline_to_br': (v: any) => any;
|
||||
'strip_html': (v: any) => string;
|
||||
'join': (v: any[], arg: string) => string;
|
||||
'last': <T>(v: T[]) => T;
|
||||
'first': <T>(v: T[]) => T;
|
||||
'map': <T1, T2>(arr: {
|
||||
[key: string]: T1;
|
||||
}[], arg: string) => T1[];
|
||||
'reverse': (v: any[]) => any[];
|
||||
'sort': <T>(v: T[], arg: (lhs: T, rhs: T) => number) => T[];
|
||||
'size': (v: string | any[]) => number;
|
||||
'concat': <T1, T2>(v: T1[], arg: T2 | T2[]) => (T1 | T2)[];
|
||||
'slice': <T>(v: T[], begin: number, length: number) => T[];
|
||||
'uniq': <T>(arr: T[]) => T[];
|
||||
'default': <T1, T2>(v: T1, arg: T2) => T1 | T2;
|
||||
'date': (v: string | Date, arg: string) => string | Date;
|
||||
'url_decode': (x: string) => string;
|
||||
'url_encode': (x: string) => string;
|
||||
'abs': (v: number) => number;
|
||||
'ceil': (v: number) => number;
|
||||
'divided_by': (v: number, arg: number) => number;
|
||||
'floor': (v: number) => number;
|
||||
'minus': (l: number, r: number) => string;
|
||||
'modulo': (l: number, r: number) => string;
|
||||
'round': (v: number, arg?: number) => number;
|
||||
'plus': (l: number, r: number) => string;
|
||||
'times': (v: number, arg: number) => number;
|
||||
'escape': (str: string) => string;
|
||||
'escape_once': (str: string) => string;
|
||||
'newline_to_br': (v: string) => string;
|
||||
'strip_html': (v: string) => string;
|
||||
};
|
||||
export default _default;
|
||||
|
||||
Vendored
+9
-9
@@ -1,12 +1,12 @@
|
||||
declare const _default: {
|
||||
'abs': (v: any) => number;
|
||||
'ceil': (v: any) => number;
|
||||
'divided_by': (v: any, arg: any) => number;
|
||||
'floor': (v: any) => number;
|
||||
'minus': (l: any, r: any) => any;
|
||||
'modulo': (l: any, r: any) => any;
|
||||
'round': (v: any, arg: any) => number;
|
||||
'plus': (l: any, r: any) => any;
|
||||
'times': (v: any, arg: any) => number;
|
||||
'abs': (v: number) => number;
|
||||
'ceil': (v: number) => number;
|
||||
'divided_by': (v: number, arg: number) => number;
|
||||
'floor': (v: number) => number;
|
||||
'minus': (l: number, r: number) => string;
|
||||
'modulo': (l: number, r: number) => string;
|
||||
'round': (v: number, arg?: number) => number;
|
||||
'plus': (l: number, r: number) => string;
|
||||
'times': (v: number, arg: number) => number;
|
||||
};
|
||||
export default _default;
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
declare const _default: {
|
||||
'default': (v: any, arg: any) => any;
|
||||
'default': <T1, T2>(v: T1, arg: T2) => T1 | T2;
|
||||
};
|
||||
export default _default;
|
||||
|
||||
Vendored
+2
-17
@@ -1,20 +1,5 @@
|
||||
import { FilterImpl } from 'src/template/filter/filter-impl';
|
||||
declare const _default: {
|
||||
'append': (v: any, arg: any) => any;
|
||||
'prepend': (v: any, arg: any) => any;
|
||||
'capitalize': (str: any) => string;
|
||||
'concat': (v: any, arg: any) => any;
|
||||
'lstrip': (v: any) => string;
|
||||
'downcase': (v: any) => any;
|
||||
'upcase': (str: any) => string;
|
||||
'remove': (v: any, arg: any) => any;
|
||||
'remove_first': (v: any, l: any) => any;
|
||||
'replace': (v: any, pattern: any, replacement: any) => string;
|
||||
'replace_first': (v: any, arg1: any, arg2: any) => string;
|
||||
'rstrip': (str: any) => string;
|
||||
'split': (v: any, arg: any) => string[];
|
||||
'strip': (v: any) => string;
|
||||
'strip_newlines': (v: any) => string;
|
||||
'truncate': (v: any, l: any, o: any) => any;
|
||||
'truncatewords': (v: any, l: any, o: any) => any;
|
||||
[key: string]: FilterImpl;
|
||||
};
|
||||
export default _default;
|
||||
|
||||
Vendored
+2
-2
@@ -1,5 +1,5 @@
|
||||
declare const _default: {
|
||||
'url_decode': (x: any) => any;
|
||||
'url_encode': (x: any) => any;
|
||||
'url_decode': (x: string) => string;
|
||||
'url_encode': (x: string) => string;
|
||||
};
|
||||
export default _default;
|
||||
|
||||
Vendored
+2
-4
@@ -1,5 +1,3 @@
|
||||
declare const _default: {
|
||||
parse: (token: any) => void;
|
||||
render: (scope: any) => Promise<string>;
|
||||
};
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options';
|
||||
declare const _default: ITagImplOptions;
|
||||
export default _default;
|
||||
|
||||
Vendored
+2
-4
@@ -1,5 +1,3 @@
|
||||
declare const _default: {
|
||||
parse: (token: any, remainTokens: any) => void;
|
||||
render: (scope: any) => Promise<any>;
|
||||
};
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options';
|
||||
declare const _default: ITagImplOptions;
|
||||
export default _default;
|
||||
|
||||
Vendored
+2
-7
@@ -1,8 +1,3 @@
|
||||
import TagToken from 'src/parser/tag-token';
|
||||
import Token from 'src/parser/token';
|
||||
import Scope from 'src/scope/scope';
|
||||
declare const _default: {
|
||||
parse: (tagToken: TagToken, remainTokens: Token[]) => void;
|
||||
render: (scope: Scope) => Promise<void>;
|
||||
};
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options';
|
||||
declare const _default: ITagImplOptions;
|
||||
export default _default;
|
||||
|
||||
Vendored
+2
-4
@@ -1,5 +1,3 @@
|
||||
declare const _default: {
|
||||
parse: (tagToken: any, remainTokens: any) => void;
|
||||
render: (scope: any) => any;
|
||||
};
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options';
|
||||
declare const _default: ITagImplOptions;
|
||||
export default _default;
|
||||
|
||||
Vendored
+2
-3
@@ -1,4 +1,3 @@
|
||||
declare const _default: {
|
||||
parse: (tagToken: any, remainTokens: any) => void;
|
||||
};
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options';
|
||||
declare const _default: ITagImplOptions;
|
||||
export default _default;
|
||||
|
||||
Vendored
+2
-4
@@ -1,5 +1,3 @@
|
||||
declare const _default: {
|
||||
parse: (tagToken: any) => void;
|
||||
render: (scope: any) => any;
|
||||
};
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options';
|
||||
declare const _default: ITagImplOptions;
|
||||
export default _default;
|
||||
|
||||
Vendored
+2
-6
@@ -1,7 +1,3 @@
|
||||
import TagToken from 'src/parser/tag-token';
|
||||
import Scope from 'src/scope/scope';
|
||||
declare const _default: {
|
||||
parse: (token: TagToken) => void;
|
||||
render: (scope: Scope) => number;
|
||||
};
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options';
|
||||
declare const _default: ITagImplOptions;
|
||||
export default _default;
|
||||
|
||||
Vendored
+2
-6
@@ -1,7 +1,3 @@
|
||||
declare function parse(tagToken: any, remainTokens: any): void;
|
||||
declare function render(scope: any, hash: any): Promise<any>;
|
||||
declare const _default: {
|
||||
parse: typeof parse;
|
||||
render: typeof render;
|
||||
};
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options';
|
||||
declare const _default: ITagImplOptions;
|
||||
export default _default;
|
||||
|
||||
Vendored
+2
-4
@@ -1,5 +1,3 @@
|
||||
declare const _default: {
|
||||
parse: (tagToken: any, remainTokens: any) => void;
|
||||
render: (scope: any) => any;
|
||||
};
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options';
|
||||
declare const _default: ITagImplOptions;
|
||||
export default _default;
|
||||
|
||||
Vendored
+2
-4
@@ -1,5 +1,3 @@
|
||||
declare const _default: {
|
||||
parse: (token: any) => void;
|
||||
render: (scope: any, hash: any) => Promise<any>;
|
||||
};
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options';
|
||||
declare const _default: ITagImplOptions;
|
||||
export default _default;
|
||||
|
||||
Vendored
+2
-4
@@ -1,5 +1,3 @@
|
||||
declare const _default: {
|
||||
parse: (token: any) => void;
|
||||
render: (scope: any) => any;
|
||||
};
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options';
|
||||
declare const _default: ITagImplOptions;
|
||||
export default _default;
|
||||
|
||||
Vendored
+2
-4
@@ -1,5 +1,3 @@
|
||||
declare const _default: {
|
||||
parse: (token: any, remainTokens: any) => void;
|
||||
render: (scope: any, hash: any) => Promise<any>;
|
||||
};
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options';
|
||||
declare const _default: ITagImplOptions;
|
||||
export default _default;
|
||||
|
||||
Vendored
+2
-4
@@ -1,5 +1,3 @@
|
||||
declare const _default: {
|
||||
parse: (tagToken: any, remainTokens: any) => void;
|
||||
render: () => any;
|
||||
};
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options';
|
||||
declare const _default: ITagImplOptions;
|
||||
export default _default;
|
||||
|
||||
Vendored
+2
-4
@@ -1,5 +1,3 @@
|
||||
declare const _default: {
|
||||
parse: (tagToken: any, remainTokens: any) => void;
|
||||
render: (scope: any, hash: any) => Promise<string>;
|
||||
};
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options';
|
||||
declare const _default: ITagImplOptions;
|
||||
export default _default;
|
||||
|
||||
Vendored
+2
-4
@@ -1,5 +1,3 @@
|
||||
declare const _default: {
|
||||
parse: (tagToken: any, remainTokens: any) => void;
|
||||
render: (scope: any) => any;
|
||||
};
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options';
|
||||
declare const _default: ITagImplOptions;
|
||||
export default _default;
|
||||
|
||||
Vendored
+1
-1
@@ -1,5 +1,5 @@
|
||||
export default interface IFS {
|
||||
exists: (filepath?: string) => Promise<boolean>;
|
||||
exists: (filepath: string) => Promise<boolean>;
|
||||
readFile: (filepath: string) => Promise<string>;
|
||||
resolve: (root: string, file: string, ext: string) => string;
|
||||
}
|
||||
|
||||
Vendored
+6
-2
@@ -42,7 +42,11 @@ export interface NormalizedFullOptions extends NormalizedOptions {
|
||||
trim_tag_left: boolean;
|
||||
trim_output_right: boolean;
|
||||
trim_output_left: boolean;
|
||||
tag_delimiter_left: string;
|
||||
tag_delimiter_right: string;
|
||||
output_delimiter_left: string;
|
||||
output_delimiter_right: string;
|
||||
greedy: boolean;
|
||||
}
|
||||
export declare function normalize(options: LiquidOptions): NormalizedOptions;
|
||||
export declare function applyDefault(options: NormalizedOptions): NormalizedFullOptions;
|
||||
export declare function normalize(options?: LiquidOptions): NormalizedOptions;
|
||||
export declare function applyDefault(options?: NormalizedOptions): NormalizedFullOptions;
|
||||
|
||||
Vendored
+194
-238
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* [email protected].0, https://github.com/harttle/liquidjs
|
||||
* [email protected].1, https://github.com/harttle/liquidjs
|
||||
* (c) 2016-2019 harttle
|
||||
* Released under the MIT License.
|
||||
*/
|
||||
@@ -166,32 +166,6 @@ function forOwn(object, iteratee) {
|
||||
}
|
||||
return object;
|
||||
}
|
||||
/*
|
||||
* Assigns own enumerable string keyed properties of source objects to the destination object.
|
||||
* Source objects are applied from left to right.
|
||||
* Subsequent sources overwrite property assignments of previous sources.
|
||||
*
|
||||
* Note: This method mutates object and is loosely based on Object.assign.
|
||||
*
|
||||
* @param {Object} object The destination object.
|
||||
* @param {...Object} sources The source objects.
|
||||
* @return {Object} Returns object.
|
||||
*/
|
||||
function assign(obj) {
|
||||
var srcs = [];
|
||||
for (var _i = 1; _i < arguments.length; _i++) {
|
||||
srcs[_i - 1] = arguments[_i];
|
||||
}
|
||||
obj = isObject(obj) ? obj : {};
|
||||
srcs.forEach(function (src) { return binaryAssign(obj, src); });
|
||||
return obj;
|
||||
}
|
||||
function binaryAssign(target, src) {
|
||||
for (var key in src)
|
||||
if (src.hasOwnProperty(key))
|
||||
target[key] = src[key];
|
||||
return target;
|
||||
}
|
||||
function last(arr) {
|
||||
return arr[arr.length - 1];
|
||||
}
|
||||
@@ -214,7 +188,7 @@ function isObject(value) {
|
||||
* negative — if you'd like a negative range, use a negative step.
|
||||
*/
|
||||
function range(start, stop, step) {
|
||||
if (arguments.length === 1) {
|
||||
if (stop === undefined) {
|
||||
stop = start;
|
||||
start = 0;
|
||||
}
|
||||
@@ -241,7 +215,7 @@ var quoted = new RegExp(singleQuoted.source + "|" + doubleQuoted.source);
|
||||
var quoteBalanced = new RegExp("(?:" + quoted.source + "|[^'\"])*");
|
||||
// basic types
|
||||
var integer = /-?\d+/;
|
||||
var number = /-?\d+\.?\d*|\.?\d+/;
|
||||
var number = /[+-]?(?:\d+\.?\d*|\.?\d+)/;
|
||||
var bool = /true|false/;
|
||||
// property access
|
||||
var identifier = /[\w-]+[?]?/;
|
||||
@@ -304,90 +278,83 @@ function parseLiteral(str) {
|
||||
throw new TypeError("cannot parse '" + str + "' as literal");
|
||||
}
|
||||
|
||||
function captureStack() {
|
||||
if (Error.captureStackTrace) {
|
||||
Error.captureStackTrace(this, this.constructor);
|
||||
}
|
||||
}
|
||||
var LiquidError = /** @class */ (function () {
|
||||
var LiquidError = /** @class */ (function (_super) {
|
||||
__extends(LiquidError, _super);
|
||||
function LiquidError(err, token) {
|
||||
this.input = token.input;
|
||||
this.file = token.file;
|
||||
this.originalError = err;
|
||||
this.token = token;
|
||||
var _this = _super.call(this, err.message) || this;
|
||||
_this.originalError = err;
|
||||
_this.token = token;
|
||||
return _this;
|
||||
}
|
||||
LiquidError.prototype.captureStackTrace = function (obj) {
|
||||
this.name = obj.constructor.name;
|
||||
captureStack.call(obj);
|
||||
LiquidError.prototype.update = function () {
|
||||
var err = this.originalError;
|
||||
var context = mkContext(this.input, this.token.line);
|
||||
var context = mkContext(this.token);
|
||||
this.message = mkMessage(err.message, this.token);
|
||||
this.stack = this.message + '\n' + context +
|
||||
'\n' + (this.stack || this.message) +
|
||||
(err.stack ? '\nFrom ' + err.stack : '');
|
||||
'\n' + this.stack + '\nFrom ' + err.stack;
|
||||
};
|
||||
return LiquidError;
|
||||
}());
|
||||
}(Error));
|
||||
var TokenizationError = /** @class */ (function (_super) {
|
||||
__extends(TokenizationError, _super);
|
||||
function TokenizationError(message, token) {
|
||||
var _this = _super.call(this, { message: message }, token) || this;
|
||||
_super.prototype.captureStackTrace.call(_this, _this);
|
||||
var _this = _super.call(this, new Error(message), token) || this;
|
||||
_this.name = 'TokenizationError';
|
||||
_super.prototype.update.call(_this);
|
||||
return _this;
|
||||
}
|
||||
return TokenizationError;
|
||||
}(LiquidError));
|
||||
TokenizationError.prototype = create(Error.prototype);
|
||||
TokenizationError.prototype.constructor = TokenizationError;
|
||||
var ParseError = /** @class */ (function (_super) {
|
||||
__extends(ParseError, _super);
|
||||
function ParseError(err, token) {
|
||||
var _this = _super.call(this, err, token) || this;
|
||||
_this.name = 'ParseError';
|
||||
_this.message = err.message;
|
||||
_super.prototype.captureStackTrace.call(_this, _this);
|
||||
_super.prototype.update.call(_this);
|
||||
return _this;
|
||||
}
|
||||
return ParseError;
|
||||
}(LiquidError));
|
||||
ParseError.prototype = create(Error.prototype);
|
||||
ParseError.prototype.constructor = ParseError;
|
||||
var RenderError = /** @class */ (function (_super) {
|
||||
__extends(RenderError, _super);
|
||||
function RenderError(err, tpl) {
|
||||
var _this = _super.call(this, err, tpl.token) || this;
|
||||
_this.name = 'RenderError';
|
||||
_this.message = err.message;
|
||||
_super.prototype.captureStackTrace.call(_this, _this);
|
||||
_super.prototype.update.call(_this);
|
||||
return _this;
|
||||
}
|
||||
return RenderError;
|
||||
}(LiquidError));
|
||||
RenderError.prototype = create(Error.prototype);
|
||||
RenderError.prototype.constructor = RenderError;
|
||||
var RenderBreakError = /** @class */ (function () {
|
||||
var RenderBreakError = /** @class */ (function (_super) {
|
||||
__extends(RenderBreakError, _super);
|
||||
function RenderBreakError(message) {
|
||||
captureStack.call(this);
|
||||
this.message = message + '';
|
||||
var _this = _super.call(this, message) || this;
|
||||
_this.resolvedHTML = '';
|
||||
_this.name = 'RenderBreakError';
|
||||
_this.message = message + '';
|
||||
return _this;
|
||||
}
|
||||
return RenderBreakError;
|
||||
}());
|
||||
RenderBreakError.prototype = create(Error.prototype);
|
||||
RenderBreakError.prototype.constructor = RenderBreakError;
|
||||
var AssertionError = /** @class */ (function () {
|
||||
}(Error));
|
||||
var AssertionError = /** @class */ (function (_super) {
|
||||
__extends(AssertionError, _super);
|
||||
function AssertionError(message) {
|
||||
captureStack.call(this);
|
||||
this.message = message + '';
|
||||
var _this = _super.call(this, message) || this;
|
||||
_this.name = 'AssertionError';
|
||||
_this.message = message + '';
|
||||
return _this;
|
||||
}
|
||||
return AssertionError;
|
||||
}());
|
||||
AssertionError.prototype = create(Error.prototype);
|
||||
AssertionError.prototype.constructor = AssertionError;
|
||||
function mkContext(input, targetLine) {
|
||||
var lines = input.split('\n');
|
||||
var begin = Math.max(targetLine - 2, 1);
|
||||
var end = Math.min(targetLine + 3, lines.length);
|
||||
}(Error));
|
||||
function mkContext(token) {
|
||||
var lines = token.input.split('\n');
|
||||
var begin = Math.max(token.line - 2, 1);
|
||||
var end = Math.min(token.line + 3, lines.length);
|
||||
var context = range(begin, end + 1)
|
||||
.map(function (lineNumber) {
|
||||
var indicator = (lineNumber === targetLine) ? '>> ' : ' ';
|
||||
var indicator = (lineNumber === token.line) ? '>> ' : ' ';
|
||||
var num = padStart(String(lineNumber), String(end).length);
|
||||
var text = lines[lineNumber - 1];
|
||||
return "" + indicator + num + "| " + text;
|
||||
@@ -396,13 +363,9 @@ function mkContext(input, targetLine) {
|
||||
return context;
|
||||
}
|
||||
function mkMessage(msg, token) {
|
||||
msg = msg || '';
|
||||
if (token.file) {
|
||||
msg += ', file:' + token.file;
|
||||
}
|
||||
if (token.line) {
|
||||
msg += ", line:" + token.line + ", col:" + token.col;
|
||||
}
|
||||
if (token.file)
|
||||
msg += ", file:" + token.file;
|
||||
msg += ", line:" + token.line + ", col:" + token.col;
|
||||
return msg;
|
||||
}
|
||||
|
||||
@@ -462,12 +425,13 @@ var Scope = /** @class */ (function () {
|
||||
function Scope(ctx, opts) {
|
||||
if (ctx === void 0) { ctx = {}; }
|
||||
this.blocks = {};
|
||||
this.groups = {};
|
||||
this.blockMode = BlockMode$1.OUTPUT;
|
||||
this.opts = applyDefault(opts);
|
||||
this.contexts = [ctx || {}];
|
||||
}
|
||||
Scope.prototype.getAll = function () {
|
||||
return this.contexts.reduce(function (ctx, val) { return assign(ctx, val); }, create(null));
|
||||
return this.contexts.reduce(function (ctx, val) { return __assign(ctx, val); }, {});
|
||||
};
|
||||
Scope.prototype.get = function (path$$1) {
|
||||
var _this = this;
|
||||
@@ -490,6 +454,7 @@ var Scope = /** @class */ (function () {
|
||||
scope[key] = {};
|
||||
}
|
||||
scope = scope[key];
|
||||
return false;
|
||||
});
|
||||
};
|
||||
Scope.prototype.unshift = function (ctx) {
|
||||
@@ -724,10 +689,12 @@ function trimRight(token, greedy) {
|
||||
}
|
||||
|
||||
var Token = /** @class */ (function () {
|
||||
function Token(raw, col, input, file, line) {
|
||||
function Token(raw, input, line, col, file) {
|
||||
this.type = 'notset';
|
||||
this.col = col;
|
||||
this.line = line;
|
||||
this.raw = raw;
|
||||
this.value = raw;
|
||||
this.input = input;
|
||||
this.file = file;
|
||||
}
|
||||
@@ -736,8 +703,8 @@ var Token = /** @class */ (function () {
|
||||
|
||||
var HTMLToken = /** @class */ (function (_super) {
|
||||
__extends(HTMLToken, _super);
|
||||
function HTMLToken(str, begin, input, file, line) {
|
||||
var _this = _super.call(this, str, begin, input, file, line) || this;
|
||||
function HTMLToken(str, input, line, col, file) {
|
||||
var _this = _super.call(this, str, input, line, col, file) || this;
|
||||
_this.type = 'html';
|
||||
_this.value = str;
|
||||
return _this;
|
||||
@@ -747,10 +714,10 @@ var HTMLToken = /** @class */ (function (_super) {
|
||||
|
||||
var DelimitedToken = /** @class */ (function (_super) {
|
||||
__extends(DelimitedToken, _super);
|
||||
function DelimitedToken(raw, value, pos, input, file, line) {
|
||||
var _this = _super.call(this, raw, pos, input, file, line) || this;
|
||||
function DelimitedToken(raw, value, input, line, pos, file) {
|
||||
var _this = _super.call(this, raw, input, line, pos, file) || this;
|
||||
_this.trimLeft = value[0] === '-';
|
||||
_this.trimRight = value[value.length - 1] === '-';
|
||||
_this.trimRight = last(value) === '-';
|
||||
_this.value = value
|
||||
.slice(_this.trimLeft ? 1 : 0, _this.trimRight ? -1 : value.length)
|
||||
.trim();
|
||||
@@ -761,8 +728,8 @@ var DelimitedToken = /** @class */ (function (_super) {
|
||||
|
||||
var TagToken = /** @class */ (function (_super) {
|
||||
__extends(TagToken, _super);
|
||||
function TagToken(raw, value$$1, pos, input, file, line) {
|
||||
var _this = _super.call(this, raw, value$$1, pos, input, file, line) || this;
|
||||
function TagToken(raw, value$$1, input, line, pos, file) {
|
||||
var _this = _super.call(this, raw, value$$1, input, line, pos, file) || this;
|
||||
_this.type = 'tag';
|
||||
var match = _this.value.match(tagLine);
|
||||
if (!match) {
|
||||
@@ -777,8 +744,8 @@ var TagToken = /** @class */ (function (_super) {
|
||||
|
||||
var OutputToken = /** @class */ (function (_super) {
|
||||
__extends(OutputToken, _super);
|
||||
function OutputToken(raw, value, pos, input, file, line) {
|
||||
var _this = _super.call(this, raw, value, pos, input, file, line) || this;
|
||||
function OutputToken(raw, value, input, line, pos, file) {
|
||||
var _this = _super.call(this, raw, value, input, line, pos, file) || this;
|
||||
_this.type = 'output';
|
||||
return _this;
|
||||
}
|
||||
@@ -816,7 +783,7 @@ var Tokenizer = /** @class */ (function () {
|
||||
if (state === ParseState.HTML) {
|
||||
if (input.substr(p, outputL.length) === outputL) {
|
||||
if (buffer)
|
||||
tokens.push(new HTMLToken(buffer, col, input, file, line));
|
||||
tokens.push(new HTMLToken(buffer, input, line, col, file));
|
||||
buffer = outputL;
|
||||
line = curLine;
|
||||
col = p - lineBegin + 1;
|
||||
@@ -826,7 +793,7 @@ var Tokenizer = /** @class */ (function () {
|
||||
}
|
||||
else if (input.substr(p, tagL.length) === tagL) {
|
||||
if (buffer)
|
||||
tokens.push(new HTMLToken(buffer, col, input, file, line));
|
||||
tokens.push(new HTMLToken(buffer, input, line, col, file));
|
||||
buffer = tagL;
|
||||
line = curLine;
|
||||
col = p - lineBegin + 1;
|
||||
@@ -837,7 +804,7 @@ var Tokenizer = /** @class */ (function () {
|
||||
}
|
||||
else if (state === ParseState.OUTPUT && input.substr(p, outputR.length) === outputR) {
|
||||
buffer += outputR;
|
||||
tokens.push(new OutputToken(buffer, buffer.slice(outputL.length, -outputR.length), col, input, file, line));
|
||||
tokens.push(new OutputToken(buffer, buffer.slice(outputL.length, -outputR.length), input, line, col, file));
|
||||
p += outputR.length;
|
||||
buffer = '';
|
||||
line = curLine;
|
||||
@@ -847,7 +814,7 @@ var Tokenizer = /** @class */ (function () {
|
||||
}
|
||||
else if (input.substr(p, tagR.length) === tagR) {
|
||||
buffer += tagR;
|
||||
tokens.push(new TagToken(buffer, buffer.slice(tagL.length, -tagR.length), col, input, file, line));
|
||||
tokens.push(new TagToken(buffer, buffer.slice(tagL.length, -tagR.length), input, line, col, file));
|
||||
p += tagR.length;
|
||||
buffer = '';
|
||||
line = curLine;
|
||||
@@ -860,10 +827,10 @@ var Tokenizer = /** @class */ (function () {
|
||||
if (state !== ParseState.HTML) {
|
||||
var t = state === ParseState.OUTPUT ? 'output' : 'tag';
|
||||
var str = buffer.length > 16 ? buffer.slice(0, 13) + '...' : buffer;
|
||||
throw new TokenizationError(new Error(t + " \"" + str + "\" not closed"), new Token(buffer, col, input, file, line));
|
||||
throw new TokenizationError(t + " \"" + str + "\" not closed", new Token(buffer, input, line, col, file));
|
||||
}
|
||||
if (buffer)
|
||||
tokens.push(new HTMLToken(buffer, col, input, file, line));
|
||||
tokens.push(new HTMLToken(buffer, input, line, col, file));
|
||||
whiteSpaceCtrl(tokens, this.options);
|
||||
return tokens;
|
||||
};
|
||||
@@ -896,11 +863,11 @@ var Render = /** @class */ (function () {
|
||||
return [3 /*break*/, 5];
|
||||
case 4:
|
||||
e_1 = _b.sent();
|
||||
if (e_1 instanceof RenderBreakError) {
|
||||
if (e_1.name === 'RenderBreakError') {
|
||||
e_1.resolvedHTML = html;
|
||||
throw e_1;
|
||||
}
|
||||
throw e_1 instanceof RenderError ? e_1 : new RenderError(e_1, tpl);
|
||||
throw e_1.name === 'RenderError' ? e_1 : new RenderError(e_1, tpl);
|
||||
case 5:
|
||||
_i++;
|
||||
return [3 /*break*/, 1];
|
||||
@@ -946,11 +913,7 @@ function evalExp(exp, scope) {
|
||||
if ((match = exp.match(rangeLine))) {
|
||||
var low = evalValue(match[1], scope);
|
||||
var high = evalValue(match[2], scope);
|
||||
var range = [];
|
||||
for (var j = low; j <= high; j++) {
|
||||
range.push(j);
|
||||
}
|
||||
return range;
|
||||
return range(low, high + 1);
|
||||
}
|
||||
return evalValue(exp, scope);
|
||||
}
|
||||
@@ -1071,8 +1034,7 @@ var Filter = /** @class */ (function () {
|
||||
};
|
||||
Filter.prototype.render = function (value$$1, scope) {
|
||||
var args = this.args.map(function (arg) { return evalValue(arg, scope); });
|
||||
args.unshift(value$$1);
|
||||
return this.impl.apply(null, args);
|
||||
return this.impl.apply(null, [value$$1].concat(args));
|
||||
};
|
||||
Filter.register = function (name, filter$$1) {
|
||||
Filter.impls[name] = filter$$1;
|
||||
@@ -1087,6 +1049,7 @@ var Filter = /** @class */ (function () {
|
||||
var ParseStream = /** @class */ (function () {
|
||||
function ParseStream(tokens, parseToken) {
|
||||
this.handlers = {};
|
||||
this.stopRequested = false;
|
||||
this.tokens = tokens;
|
||||
this.parseToken = parseToken;
|
||||
}
|
||||
@@ -1100,6 +1063,7 @@ var ParseStream = /** @class */ (function () {
|
||||
h(arg);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
ParseStream.prototype.start = function () {
|
||||
this.trigger('start');
|
||||
@@ -1107,8 +1071,7 @@ var ParseStream = /** @class */ (function () {
|
||||
while (!this.stopRequested && (token = this.tokens.shift())) {
|
||||
if (this.trigger('token', token))
|
||||
continue;
|
||||
if (token.type === 'tag' &&
|
||||
this.trigger("tag:" + token.name, token)) {
|
||||
if (token.type === 'tag' && this.trigger("tag:" + token.name, token)) {
|
||||
continue;
|
||||
}
|
||||
var template = this.parseToken(token, this.tokens);
|
||||
@@ -1127,16 +1090,14 @@ var ParseStream = /** @class */ (function () {
|
||||
|
||||
var default_1 = /** @class */ (function () {
|
||||
function default_1(str, strictFilters) {
|
||||
this.filters = [];
|
||||
var match = matchValue(str);
|
||||
assert(match, "illegal value string: " + str);
|
||||
var initial = match[0];
|
||||
this.initial = match[0];
|
||||
str = str.substr(match.index + match[0].length);
|
||||
var filters = [];
|
||||
while ((match = filter.exec(str))) {
|
||||
filters.push([match[0].trim()]);
|
||||
this.filters.push(new Filter(match[0].trim(), strictFilters));
|
||||
}
|
||||
this.initial = initial;
|
||||
this.filters = filters.map(function (str) { return new Filter(str, strictFilters); });
|
||||
}
|
||||
default_1.prototype.value = function (scope) {
|
||||
return this.filters.reduce(function (prev, filter$$1) { return filter$$1.render(prev, scope); }, evalExp(this.initial, scope));
|
||||
@@ -1218,7 +1179,7 @@ var Parser = /** @class */ (function () {
|
||||
}());
|
||||
|
||||
var re = new RegExp("(" + identifier.source + ")\\s*=([^]*)");
|
||||
var assign$1 = {
|
||||
var assign = {
|
||||
parse: function (token) {
|
||||
var match = token.args.match(re);
|
||||
assert(match, "illegal token " + token.raw);
|
||||
@@ -1233,12 +1194,6 @@ var assign$1 = {
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
* Call functions in serial until someone resolved.
|
||||
* @param iterable the array to iterate with.
|
||||
* @param iteratee returns a new promise.
|
||||
* The iteratee is invoked with three arguments: (value, index, iterable).
|
||||
*/
|
||||
/*
|
||||
* Call functions in serial until someone rejected.
|
||||
* @param {Array} iterable the array to iterate with.
|
||||
@@ -1246,7 +1201,7 @@ var assign$1 = {
|
||||
* The iteratee is invoked with three arguments: (value, index, iterable).
|
||||
*/
|
||||
function mapSeries(iterable, iteratee) {
|
||||
var ret = Promise.resolve('init');
|
||||
var ret = Promise.resolve(0);
|
||||
var result = [];
|
||||
iterable.forEach(function (item, idx) {
|
||||
ret = ret
|
||||
@@ -1261,107 +1216,109 @@ var re$1 = new RegExp("^(" + identifier.source + ")\\s+in\\s+" +
|
||||
("(?:\\s+" + hash.source + ")*") +
|
||||
"(?:\\s+(reversed))?" +
|
||||
("(?:\\s+" + hash.source + ")*$"));
|
||||
function parse(tagToken, remainTokens) {
|
||||
var _this = this;
|
||||
var match = re$1.exec(tagToken.args);
|
||||
assert(match, "illegal tag: " + tagToken.raw);
|
||||
this.variable = match[1];
|
||||
this.collection = match[2];
|
||||
this.reversed = !!match[3];
|
||||
this.templates = [];
|
||||
this.elseTemplates = [];
|
||||
var p;
|
||||
var stream = this.liquid.parser.parseStream(remainTokens)
|
||||
.on('start', function () { return (p = _this.templates); })
|
||||
.on('tag:else', function () { return (p = _this.elseTemplates); })
|
||||
.on('tag:endfor', function () { return stream.stop(); })
|
||||
.on('template', function (tpl) { return p.push(tpl); })
|
||||
.on('end', function () {
|
||||
throw new Error("tag " + tagToken.raw + " not closed");
|
||||
});
|
||||
stream.start();
|
||||
}
|
||||
function render(scope, hash$$1) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var collection, offset, limit, contexts, html, finished;
|
||||
var For = {
|
||||
type: 'block',
|
||||
parse: function (tagToken, remainTokens) {
|
||||
var _this = this;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
collection = evalExp(this.collection, scope);
|
||||
if (!isArray(collection)) {
|
||||
if (isString(collection) && collection.length > 0) {
|
||||
collection = [collection];
|
||||
}
|
||||
else if (isObject(collection)) {
|
||||
collection = Object.keys(collection).map(function (key) { return [key, collection[key]]; });
|
||||
}
|
||||
}
|
||||
if (!isArray(collection) || !collection.length) {
|
||||
return [2 /*return*/, this.liquid.renderer.renderTemplates(this.elseTemplates, scope)];
|
||||
}
|
||||
offset = hash$$1.offset || 0;
|
||||
limit = (hash$$1.limit === undefined) ? collection.length : hash$$1.limit;
|
||||
collection = collection.slice(offset, offset + limit);
|
||||
if (this.reversed)
|
||||
collection.reverse();
|
||||
contexts = collection.map(function (item, i) {
|
||||
var ctx = {};
|
||||
ctx[_this.variable] = item;
|
||||
ctx['forloop'] = {
|
||||
first: i === 0,
|
||||
index: i + 1,
|
||||
index0: i,
|
||||
last: i === collection.length - 1,
|
||||
length: collection.length,
|
||||
rindex: collection.length - i,
|
||||
rindex0: collection.length - i - 1
|
||||
};
|
||||
return ctx;
|
||||
});
|
||||
html = '';
|
||||
finished = false;
|
||||
return [4 /*yield*/, mapSeries(contexts, function (context) { return __awaiter(_this, void 0, void 0, function () {
|
||||
var _a, e_1;
|
||||
return __generator(this, function (_b) {
|
||||
switch (_b.label) {
|
||||
case 0:
|
||||
if (finished)
|
||||
return [2 /*return*/];
|
||||
scope.push(context);
|
||||
_b.label = 1;
|
||||
case 1:
|
||||
_b.trys.push([1, 3, , 4]);
|
||||
_a = html;
|
||||
return [4 /*yield*/, this.liquid.renderer.renderTemplates(this.templates, scope)];
|
||||
case 2:
|
||||
html = _a + _b.sent();
|
||||
return [3 /*break*/, 4];
|
||||
case 3:
|
||||
e_1 = _b.sent();
|
||||
if (e_1 instanceof RenderBreakError) {
|
||||
html += e_1.resolvedHTML;
|
||||
if (e_1.message === 'break') {
|
||||
finished = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
throw e_1;
|
||||
return [3 /*break*/, 4];
|
||||
case 4:
|
||||
scope.pop(context);
|
||||
return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
}); })];
|
||||
case 1:
|
||||
_a.sent();
|
||||
return [2 /*return*/, html];
|
||||
}
|
||||
var match = re$1.exec(tagToken.args);
|
||||
assert(match, "illegal tag: " + tagToken.raw);
|
||||
this.variable = match[1];
|
||||
this.collection = match[2];
|
||||
this.reversed = !!match[3];
|
||||
this.templates = [];
|
||||
this.elseTemplates = [];
|
||||
var p;
|
||||
var stream = this.liquid.parser.parseStream(remainTokens)
|
||||
.on('start', function () { return (p = _this.templates); })
|
||||
.on('tag:else', function () { return (p = _this.elseTemplates); })
|
||||
.on('tag:endfor', function () { return stream.stop(); })
|
||||
.on('template', function (tpl) { return p.push(tpl); })
|
||||
.on('end', function () {
|
||||
throw new Error("tag " + tagToken.raw + " not closed");
|
||||
});
|
||||
});
|
||||
}
|
||||
var For = { parse: parse, render: render };
|
||||
stream.start();
|
||||
},
|
||||
render: function (scope, hash$$1) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var collection, offset, limit, contexts, html, finished;
|
||||
var _this = this;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
collection = evalExp(this.collection, scope);
|
||||
if (!isArray(collection)) {
|
||||
if (isString(collection) && collection.length > 0) {
|
||||
collection = [collection];
|
||||
}
|
||||
else if (isObject(collection)) {
|
||||
collection = Object.keys(collection).map(function (key) { return [key, collection[key]]; });
|
||||
}
|
||||
}
|
||||
if (!isArray(collection) || !collection.length) {
|
||||
return [2 /*return*/, this.liquid.renderer.renderTemplates(this.elseTemplates, scope)];
|
||||
}
|
||||
offset = hash$$1.offset || 0;
|
||||
limit = (hash$$1.limit === undefined) ? collection.length : hash$$1.limit;
|
||||
collection = collection.slice(offset, offset + limit);
|
||||
if (this.reversed)
|
||||
collection.reverse();
|
||||
contexts = collection.map(function (item, i) {
|
||||
var ctx = {};
|
||||
ctx[_this.variable] = item;
|
||||
ctx['forloop'] = {
|
||||
first: i === 0,
|
||||
index: i + 1,
|
||||
index0: i,
|
||||
last: i === collection.length - 1,
|
||||
length: collection.length,
|
||||
rindex: collection.length - i,
|
||||
rindex0: collection.length - i - 1
|
||||
};
|
||||
return ctx;
|
||||
});
|
||||
html = '';
|
||||
finished = false;
|
||||
return [4 /*yield*/, mapSeries(contexts, function (context) { return __awaiter(_this, void 0, void 0, function () {
|
||||
var _a, e_1;
|
||||
return __generator(this, function (_b) {
|
||||
switch (_b.label) {
|
||||
case 0:
|
||||
if (finished)
|
||||
return [2 /*return*/];
|
||||
scope.push(context);
|
||||
_b.label = 1;
|
||||
case 1:
|
||||
_b.trys.push([1, 3, , 4]);
|
||||
_a = html;
|
||||
return [4 /*yield*/, this.liquid.renderer.renderTemplates(this.templates, scope)];
|
||||
case 2:
|
||||
html = _a + _b.sent();
|
||||
return [3 /*break*/, 4];
|
||||
case 3:
|
||||
e_1 = _b.sent();
|
||||
if (e_1.name === 'RenderBreakError') {
|
||||
html += e_1.resolvedHTML;
|
||||
if (e_1.message === 'break') {
|
||||
finished = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
throw e_1;
|
||||
return [3 /*break*/, 4];
|
||||
case 4:
|
||||
scope.pop(context);
|
||||
return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
}); })];
|
||||
case 1:
|
||||
_a.sent();
|
||||
return [2 /*return*/, html];
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
var re$2 = new RegExp("(" + identifier.source + ")");
|
||||
var capture = {
|
||||
@@ -1548,7 +1505,7 @@ var cycle = {
|
||||
render: function (scope) {
|
||||
var group = evalValue(this.group, scope);
|
||||
var fingerprint = "cycle:" + group + ":" + this.candidates.join(',');
|
||||
var groups = scope.opts.groups = scope.opts.groups || {};
|
||||
var groups = scope.groups;
|
||||
var idx = groups[fingerprint];
|
||||
if (idx === undefined) {
|
||||
idx = groups[fingerprint] = 0;
|
||||
@@ -1768,6 +1725,7 @@ var tablerow = {
|
||||
ctx[_this.variable] = item;
|
||||
return ctx;
|
||||
});
|
||||
row = 0;
|
||||
html = '';
|
||||
return [4 /*yield*/, mapSeries(contexts, function (context, idx) { return __awaiter(_this, void 0, void 0, function () {
|
||||
var col, _a;
|
||||
@@ -1854,7 +1812,7 @@ var Continue = {
|
||||
};
|
||||
|
||||
var tags = {
|
||||
assign: assign$1, 'for': For, capture: capture, 'case': Case, comment: comment, include: include, decrement: decrement, increment: increment, cycle: cycle, 'if': If, layout: layout, block: block, raw: raw, tablerow: tablerow, unless: unless, 'break': Break, 'continue': Continue
|
||||
assign: assign, 'for': For, capture: capture, 'case': Case, comment: comment, include: include, decrement: decrement, increment: increment, cycle: cycle, 'if': If, layout: layout, block: block, raw: raw, tablerow: tablerow, unless: unless, 'break': Break, 'continue': Continue
|
||||
};
|
||||
|
||||
var escapeMap = {
|
||||
@@ -1881,14 +1839,13 @@ var html = {
|
||||
'escape': escape,
|
||||
'escape_once': function (str) { return escape(unescape(str)); },
|
||||
'newline_to_br': function (v) { return v.replace(/\n/g, '<br />'); },
|
||||
'strip_html': function (v) { return String(v).replace(/<script.*?<\/script>|<!--.*?-->|<style.*?<\/style>|<.*?>/g, ''); }
|
||||
'strip_html': function (v) { return v.replace(/<script.*?<\/script>|<!--.*?-->|<style.*?<\/style>|<.*?>/g, ''); }
|
||||
};
|
||||
|
||||
var str = {
|
||||
'append': function (v, arg) { return v + arg; },
|
||||
'prepend': function (v, arg) { return arg + v; },
|
||||
'capitalize': function (str) { return String(str).charAt(0).toUpperCase() + str.slice(1); },
|
||||
'concat': function (v, arg) { return Array.prototype.concat.call(v, arg); },
|
||||
'lstrip': function (v) { return String(v).replace(/^\s+/, ''); },
|
||||
'downcase': function (v) { return v.toLowerCase(); },
|
||||
'upcase': function (str) { return String(str).toUpperCase(); },
|
||||
@@ -1903,19 +1860,19 @@ var str = {
|
||||
'strip': function (v) { return String(v).trim(); },
|
||||
'strip_newlines': function (v) { return String(v).replace(/\n/g, ''); },
|
||||
'truncate': function (v, l, o) {
|
||||
if (l === void 0) { l = 50; }
|
||||
if (o === void 0) { o = '...'; }
|
||||
v = String(v);
|
||||
o = (o === undefined) ? '...' : o;
|
||||
l = l || 16;
|
||||
if (v.length <= l)
|
||||
return v;
|
||||
return v.substr(0, l - o.length) + o;
|
||||
},
|
||||
'truncatewords': function (v, l, o) {
|
||||
if (o === undefined)
|
||||
o = '...';
|
||||
var arr = v.split(' ');
|
||||
if (l === void 0) { l = 15; }
|
||||
if (o === void 0) { o = '...'; }
|
||||
var arr = v.split(/\s+/);
|
||||
var ret = arr.slice(0, l).join(' ');
|
||||
if (arr.length > l)
|
||||
if (arr.length >= l)
|
||||
ret += o;
|
||||
return ret;
|
||||
}
|
||||
@@ -1929,7 +1886,8 @@ var math = {
|
||||
'minus': bindFixed(function (v, arg) { return v - arg; }),
|
||||
'modulo': bindFixed(function (v, arg) { return v % arg; }),
|
||||
'round': function (v, arg) {
|
||||
var amp = Math.pow(10, arg || 0);
|
||||
if (arg === void 0) { arg = 0; }
|
||||
var amp = Math.pow(10, arg);
|
||||
return Math.round(v * amp) / amp;
|
||||
},
|
||||
'plus': bindFixed(function (v, arg) { return Number(v) + Number(arg); }),
|
||||
@@ -1959,6 +1917,7 @@ var array = {
|
||||
'reverse': function (v) { return v.reverse(); },
|
||||
'sort': function (v, arg) { return v.sort(arg); },
|
||||
'size': function (v) { return v.length; },
|
||||
'concat': function (v, arg) { return Array.prototype.concat.call(v, arg); },
|
||||
'slice': function (v, begin, length) {
|
||||
if (length === undefined)
|
||||
length = 1;
|
||||
@@ -1967,10 +1926,9 @@ var array = {
|
||||
'uniq': function (arr) {
|
||||
var u = {};
|
||||
return (arr || []).filter(function (val) {
|
||||
if (u.hasOwnProperty(val)) {
|
||||
if (u.hasOwnProperty(String(val)))
|
||||
return false;
|
||||
}
|
||||
u[val] = true;
|
||||
u[String(val)] = true;
|
||||
return true;
|
||||
});
|
||||
}
|
||||
@@ -2142,7 +2100,7 @@ function strftime (d, format) {
|
||||
// Add the format code
|
||||
var ch = results[0].charAt(1);
|
||||
var func = formatCodes[ch];
|
||||
output += func ? func.call(this, d) : '%' + ch;
|
||||
output += func ? func(d) : '%' + ch;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2172,10 +2130,8 @@ var Liquid = /** @class */ (function () {
|
||||
function Liquid(opts) {
|
||||
if (opts === void 0) { opts = {}; }
|
||||
var _this = this;
|
||||
this.cache = {};
|
||||
this.options = applyDefault(normalize(opts));
|
||||
if (this.options.cache) {
|
||||
this.cache = {};
|
||||
}
|
||||
this.parser = new Parser(this);
|
||||
this.renderer = new Render();
|
||||
this.tokenizer = new Tokenizer(this.options);
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+11
-8
@@ -1,26 +1,29 @@
|
||||
import Scope from './scope/scope';
|
||||
import * as Types from './types';
|
||||
import ITemplate from './template/itemplate';
|
||||
import Render from './render/render';
|
||||
import Parser from './parser/parser';
|
||||
import ITagImplOptions from './template/tag/itag-impl-options';
|
||||
import { isTruthy, isFalsy, evalExp, evalValue } from './render/syntax';
|
||||
import { LiquidOptions, NormalizedFullOptions } from './liquid-options';
|
||||
import { FilterImpl } from './template/filter/filter-impl';
|
||||
export default class Liquid {
|
||||
options: NormalizedFullOptions;
|
||||
renderer: Render;
|
||||
parser: Parser;
|
||||
private cache;
|
||||
private parser;
|
||||
private renderer;
|
||||
private tokenizer;
|
||||
constructor(opts?: LiquidOptions);
|
||||
parse(html: string, filepath?: string): any[];
|
||||
parse(html: string, filepath?: string): ITemplate[];
|
||||
render(tpl: Array<ITemplate>, ctx?: object, opts?: LiquidOptions): Promise<string>;
|
||||
parseAndRender(html: string, ctx?: object, opts?: LiquidOptions): Promise<string>;
|
||||
getTemplate(file: any, opts?: LiquidOptions): Promise<any>;
|
||||
renderFile(file: any, ctx?: object, opts?: LiquidOptions): Promise<string>;
|
||||
getTemplate(file: string, opts?: LiquidOptions): Promise<any>;
|
||||
renderFile(file: string, ctx?: object, opts?: LiquidOptions): Promise<string>;
|
||||
evalValue(str: string, scope: Scope): any;
|
||||
registerFilter(name: any, filter: any): void;
|
||||
registerFilter(name: string, filter: FilterImpl): void;
|
||||
registerTag(name: string, tag: ITagImplOptions): void;
|
||||
plugin(plugin: any): any;
|
||||
express(): (filePath: string, ctx: object, cb: (err: Error, html?: string) => void) => void;
|
||||
plugin(plugin: (this: Liquid, L: typeof Liquid) => void): void;
|
||||
express(): (this: any, filePath: string, ctx: object, cb: (err: Error | null, html?: string | undefined) => void) => void;
|
||||
static default: typeof Liquid;
|
||||
static isTruthy: typeof isTruthy;
|
||||
static isFalsy: typeof isFalsy;
|
||||
|
||||
Vendored
+194
-238
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* liquidjs@7.2.0, https://github.com/harttle/liquidjs
|
||||
* liquidjs@7.2.1, https://github.com/harttle/liquidjs
|
||||
* (c) 2016-2019 harttle
|
||||
* Released under the MIT License.
|
||||
*/
|
||||
@@ -154,32 +154,6 @@
|
||||
}
|
||||
return object;
|
||||
}
|
||||
/*
|
||||
* Assigns own enumerable string keyed properties of source objects to the destination object.
|
||||
* Source objects are applied from left to right.
|
||||
* Subsequent sources overwrite property assignments of previous sources.
|
||||
*
|
||||
* Note: This method mutates object and is loosely based on Object.assign.
|
||||
*
|
||||
* @param {Object} object The destination object.
|
||||
* @param {...Object} sources The source objects.
|
||||
* @return {Object} Returns object.
|
||||
*/
|
||||
function assign(obj) {
|
||||
var srcs = [];
|
||||
for (var _i = 1; _i < arguments.length; _i++) {
|
||||
srcs[_i - 1] = arguments[_i];
|
||||
}
|
||||
obj = isObject(obj) ? obj : {};
|
||||
srcs.forEach(function (src) { return binaryAssign(obj, src); });
|
||||
return obj;
|
||||
}
|
||||
function binaryAssign(target, src) {
|
||||
for (var key in src)
|
||||
if (src.hasOwnProperty(key))
|
||||
target[key] = src[key];
|
||||
return target;
|
||||
}
|
||||
function last(arr) {
|
||||
return arr[arr.length - 1];
|
||||
}
|
||||
@@ -202,7 +176,7 @@
|
||||
* negative — if you'd like a negative range, use a negative step.
|
||||
*/
|
||||
function range(start, stop, step) {
|
||||
if (arguments.length === 1) {
|
||||
if (stop === undefined) {
|
||||
stop = start;
|
||||
start = 0;
|
||||
}
|
||||
@@ -229,7 +203,7 @@
|
||||
var quoteBalanced = new RegExp("(?:" + quoted.source + "|[^'\"])*");
|
||||
// basic types
|
||||
var integer = /-?\d+/;
|
||||
var number = /-?\d+\.?\d*|\.?\d+/;
|
||||
var number = /[+-]?(?:\d+\.?\d*|\.?\d+)/;
|
||||
var bool = /true|false/;
|
||||
// property access
|
||||
var identifier = /[\w-]+[?]?/;
|
||||
@@ -292,90 +266,83 @@
|
||||
throw new TypeError("cannot parse '" + str + "' as literal");
|
||||
}
|
||||
|
||||
function captureStack() {
|
||||
if (Error.captureStackTrace) {
|
||||
Error.captureStackTrace(this, this.constructor);
|
||||
}
|
||||
}
|
||||
var LiquidError = /** @class */ (function () {
|
||||
var LiquidError = /** @class */ (function (_super) {
|
||||
__extends(LiquidError, _super);
|
||||
function LiquidError(err, token) {
|
||||
this.input = token.input;
|
||||
this.file = token.file;
|
||||
this.originalError = err;
|
||||
this.token = token;
|
||||
var _this = _super.call(this, err.message) || this;
|
||||
_this.originalError = err;
|
||||
_this.token = token;
|
||||
return _this;
|
||||
}
|
||||
LiquidError.prototype.captureStackTrace = function (obj) {
|
||||
this.name = obj.constructor.name;
|
||||
captureStack.call(obj);
|
||||
LiquidError.prototype.update = function () {
|
||||
var err = this.originalError;
|
||||
var context = mkContext(this.input, this.token.line);
|
||||
var context = mkContext(this.token);
|
||||
this.message = mkMessage(err.message, this.token);
|
||||
this.stack = this.message + '\n' + context +
|
||||
'\n' + (this.stack || this.message) +
|
||||
(err.stack ? '\nFrom ' + err.stack : '');
|
||||
'\n' + this.stack + '\nFrom ' + err.stack;
|
||||
};
|
||||
return LiquidError;
|
||||
}());
|
||||
}(Error));
|
||||
var TokenizationError = /** @class */ (function (_super) {
|
||||
__extends(TokenizationError, _super);
|
||||
function TokenizationError(message, token) {
|
||||
var _this = _super.call(this, { message: message }, token) || this;
|
||||
_super.prototype.captureStackTrace.call(_this, _this);
|
||||
var _this = _super.call(this, new Error(message), token) || this;
|
||||
_this.name = 'TokenizationError';
|
||||
_super.prototype.update.call(_this);
|
||||
return _this;
|
||||
}
|
||||
return TokenizationError;
|
||||
}(LiquidError));
|
||||
TokenizationError.prototype = create(Error.prototype);
|
||||
TokenizationError.prototype.constructor = TokenizationError;
|
||||
var ParseError = /** @class */ (function (_super) {
|
||||
__extends(ParseError, _super);
|
||||
function ParseError(err, token) {
|
||||
var _this = _super.call(this, err, token) || this;
|
||||
_this.name = 'ParseError';
|
||||
_this.message = err.message;
|
||||
_super.prototype.captureStackTrace.call(_this, _this);
|
||||
_super.prototype.update.call(_this);
|
||||
return _this;
|
||||
}
|
||||
return ParseError;
|
||||
}(LiquidError));
|
||||
ParseError.prototype = create(Error.prototype);
|
||||
ParseError.prototype.constructor = ParseError;
|
||||
var RenderError = /** @class */ (function (_super) {
|
||||
__extends(RenderError, _super);
|
||||
function RenderError(err, tpl) {
|
||||
var _this = _super.call(this, err, tpl.token) || this;
|
||||
_this.name = 'RenderError';
|
||||
_this.message = err.message;
|
||||
_super.prototype.captureStackTrace.call(_this, _this);
|
||||
_super.prototype.update.call(_this);
|
||||
return _this;
|
||||
}
|
||||
return RenderError;
|
||||
}(LiquidError));
|
||||
RenderError.prototype = create(Error.prototype);
|
||||
RenderError.prototype.constructor = RenderError;
|
||||
var RenderBreakError = /** @class */ (function () {
|
||||
var RenderBreakError = /** @class */ (function (_super) {
|
||||
__extends(RenderBreakError, _super);
|
||||
function RenderBreakError(message) {
|
||||
captureStack.call(this);
|
||||
this.message = message + '';
|
||||
var _this = _super.call(this, message) || this;
|
||||
_this.resolvedHTML = '';
|
||||
_this.name = 'RenderBreakError';
|
||||
_this.message = message + '';
|
||||
return _this;
|
||||
}
|
||||
return RenderBreakError;
|
||||
}());
|
||||
RenderBreakError.prototype = create(Error.prototype);
|
||||
RenderBreakError.prototype.constructor = RenderBreakError;
|
||||
var AssertionError = /** @class */ (function () {
|
||||
}(Error));
|
||||
var AssertionError = /** @class */ (function (_super) {
|
||||
__extends(AssertionError, _super);
|
||||
function AssertionError(message) {
|
||||
captureStack.call(this);
|
||||
this.message = message + '';
|
||||
var _this = _super.call(this, message) || this;
|
||||
_this.name = 'AssertionError';
|
||||
_this.message = message + '';
|
||||
return _this;
|
||||
}
|
||||
return AssertionError;
|
||||
}());
|
||||
AssertionError.prototype = create(Error.prototype);
|
||||
AssertionError.prototype.constructor = AssertionError;
|
||||
function mkContext(input, targetLine) {
|
||||
var lines = input.split('\n');
|
||||
var begin = Math.max(targetLine - 2, 1);
|
||||
var end = Math.min(targetLine + 3, lines.length);
|
||||
}(Error));
|
||||
function mkContext(token) {
|
||||
var lines = token.input.split('\n');
|
||||
var begin = Math.max(token.line - 2, 1);
|
||||
var end = Math.min(token.line + 3, lines.length);
|
||||
var context = range(begin, end + 1)
|
||||
.map(function (lineNumber) {
|
||||
var indicator = (lineNumber === targetLine) ? '>> ' : ' ';
|
||||
var indicator = (lineNumber === token.line) ? '>> ' : ' ';
|
||||
var num = padStart(String(lineNumber), String(end).length);
|
||||
var text = lines[lineNumber - 1];
|
||||
return "" + indicator + num + "| " + text;
|
||||
@@ -384,13 +351,9 @@
|
||||
return context;
|
||||
}
|
||||
function mkMessage(msg, token) {
|
||||
msg = msg || '';
|
||||
if (token.file) {
|
||||
msg += ', file:' + token.file;
|
||||
}
|
||||
if (token.line) {
|
||||
msg += ", line:" + token.line + ", col:" + token.col;
|
||||
}
|
||||
if (token.file)
|
||||
msg += ", file:" + token.file;
|
||||
msg += ", line:" + token.line + ", col:" + token.col;
|
||||
return msg;
|
||||
}
|
||||
|
||||
@@ -450,12 +413,13 @@
|
||||
function Scope(ctx, opts) {
|
||||
if (ctx === void 0) { ctx = {}; }
|
||||
this.blocks = {};
|
||||
this.groups = {};
|
||||
this.blockMode = BlockMode$1.OUTPUT;
|
||||
this.opts = applyDefault(opts);
|
||||
this.contexts = [ctx || {}];
|
||||
}
|
||||
Scope.prototype.getAll = function () {
|
||||
return this.contexts.reduce(function (ctx, val) { return assign(ctx, val); }, create(null));
|
||||
return this.contexts.reduce(function (ctx, val) { return __assign(ctx, val); }, {});
|
||||
};
|
||||
Scope.prototype.get = function (path) {
|
||||
var _this = this;
|
||||
@@ -478,6 +442,7 @@
|
||||
scope[key] = {};
|
||||
}
|
||||
scope = scope[key];
|
||||
return false;
|
||||
});
|
||||
};
|
||||
Scope.prototype.unshift = function (ctx) {
|
||||
@@ -749,10 +714,12 @@
|
||||
}
|
||||
|
||||
var Token = /** @class */ (function () {
|
||||
function Token(raw, col, input, file, line) {
|
||||
function Token(raw, input, line, col, file) {
|
||||
this.type = 'notset';
|
||||
this.col = col;
|
||||
this.line = line;
|
||||
this.raw = raw;
|
||||
this.value = raw;
|
||||
this.input = input;
|
||||
this.file = file;
|
||||
}
|
||||
@@ -761,8 +728,8 @@
|
||||
|
||||
var HTMLToken = /** @class */ (function (_super) {
|
||||
__extends(HTMLToken, _super);
|
||||
function HTMLToken(str, begin, input, file, line) {
|
||||
var _this = _super.call(this, str, begin, input, file, line) || this;
|
||||
function HTMLToken(str, input, line, col, file) {
|
||||
var _this = _super.call(this, str, input, line, col, file) || this;
|
||||
_this.type = 'html';
|
||||
_this.value = str;
|
||||
return _this;
|
||||
@@ -772,10 +739,10 @@
|
||||
|
||||
var DelimitedToken = /** @class */ (function (_super) {
|
||||
__extends(DelimitedToken, _super);
|
||||
function DelimitedToken(raw, value, pos, input, file, line) {
|
||||
var _this = _super.call(this, raw, pos, input, file, line) || this;
|
||||
function DelimitedToken(raw, value, input, line, pos, file) {
|
||||
var _this = _super.call(this, raw, input, line, pos, file) || this;
|
||||
_this.trimLeft = value[0] === '-';
|
||||
_this.trimRight = value[value.length - 1] === '-';
|
||||
_this.trimRight = last(value) === '-';
|
||||
_this.value = value
|
||||
.slice(_this.trimLeft ? 1 : 0, _this.trimRight ? -1 : value.length)
|
||||
.trim();
|
||||
@@ -786,8 +753,8 @@
|
||||
|
||||
var TagToken = /** @class */ (function (_super) {
|
||||
__extends(TagToken, _super);
|
||||
function TagToken(raw, value$$1, pos, input, file, line) {
|
||||
var _this = _super.call(this, raw, value$$1, pos, input, file, line) || this;
|
||||
function TagToken(raw, value$$1, input, line, pos, file) {
|
||||
var _this = _super.call(this, raw, value$$1, input, line, pos, file) || this;
|
||||
_this.type = 'tag';
|
||||
var match = _this.value.match(tagLine);
|
||||
if (!match) {
|
||||
@@ -802,8 +769,8 @@
|
||||
|
||||
var OutputToken = /** @class */ (function (_super) {
|
||||
__extends(OutputToken, _super);
|
||||
function OutputToken(raw, value, pos, input, file, line) {
|
||||
var _this = _super.call(this, raw, value, pos, input, file, line) || this;
|
||||
function OutputToken(raw, value, input, line, pos, file) {
|
||||
var _this = _super.call(this, raw, value, input, line, pos, file) || this;
|
||||
_this.type = 'output';
|
||||
return _this;
|
||||
}
|
||||
@@ -841,7 +808,7 @@
|
||||
if (state === ParseState.HTML) {
|
||||
if (input.substr(p, outputL.length) === outputL) {
|
||||
if (buffer)
|
||||
tokens.push(new HTMLToken(buffer, col, input, file, line));
|
||||
tokens.push(new HTMLToken(buffer, input, line, col, file));
|
||||
buffer = outputL;
|
||||
line = curLine;
|
||||
col = p - lineBegin + 1;
|
||||
@@ -851,7 +818,7 @@
|
||||
}
|
||||
else if (input.substr(p, tagL.length) === tagL) {
|
||||
if (buffer)
|
||||
tokens.push(new HTMLToken(buffer, col, input, file, line));
|
||||
tokens.push(new HTMLToken(buffer, input, line, col, file));
|
||||
buffer = tagL;
|
||||
line = curLine;
|
||||
col = p - lineBegin + 1;
|
||||
@@ -862,7 +829,7 @@
|
||||
}
|
||||
else if (state === ParseState.OUTPUT && input.substr(p, outputR.length) === outputR) {
|
||||
buffer += outputR;
|
||||
tokens.push(new OutputToken(buffer, buffer.slice(outputL.length, -outputR.length), col, input, file, line));
|
||||
tokens.push(new OutputToken(buffer, buffer.slice(outputL.length, -outputR.length), input, line, col, file));
|
||||
p += outputR.length;
|
||||
buffer = '';
|
||||
line = curLine;
|
||||
@@ -872,7 +839,7 @@
|
||||
}
|
||||
else if (input.substr(p, tagR.length) === tagR) {
|
||||
buffer += tagR;
|
||||
tokens.push(new TagToken(buffer, buffer.slice(tagL.length, -tagR.length), col, input, file, line));
|
||||
tokens.push(new TagToken(buffer, buffer.slice(tagL.length, -tagR.length), input, line, col, file));
|
||||
p += tagR.length;
|
||||
buffer = '';
|
||||
line = curLine;
|
||||
@@ -885,10 +852,10 @@
|
||||
if (state !== ParseState.HTML) {
|
||||
var t = state === ParseState.OUTPUT ? 'output' : 'tag';
|
||||
var str = buffer.length > 16 ? buffer.slice(0, 13) + '...' : buffer;
|
||||
throw new TokenizationError(new Error(t + " \"" + str + "\" not closed"), new Token(buffer, col, input, file, line));
|
||||
throw new TokenizationError(t + " \"" + str + "\" not closed", new Token(buffer, input, line, col, file));
|
||||
}
|
||||
if (buffer)
|
||||
tokens.push(new HTMLToken(buffer, col, input, file, line));
|
||||
tokens.push(new HTMLToken(buffer, input, line, col, file));
|
||||
whiteSpaceCtrl(tokens, this.options);
|
||||
return tokens;
|
||||
};
|
||||
@@ -921,11 +888,11 @@
|
||||
return [3 /*break*/, 5];
|
||||
case 4:
|
||||
e_1 = _b.sent();
|
||||
if (e_1 instanceof RenderBreakError) {
|
||||
if (e_1.name === 'RenderBreakError') {
|
||||
e_1.resolvedHTML = html;
|
||||
throw e_1;
|
||||
}
|
||||
throw e_1 instanceof RenderError ? e_1 : new RenderError(e_1, tpl);
|
||||
throw e_1.name === 'RenderError' ? e_1 : new RenderError(e_1, tpl);
|
||||
case 5:
|
||||
_i++;
|
||||
return [3 /*break*/, 1];
|
||||
@@ -971,11 +938,7 @@
|
||||
if ((match = exp.match(rangeLine))) {
|
||||
var low = evalValue(match[1], scope);
|
||||
var high = evalValue(match[2], scope);
|
||||
var range = [];
|
||||
for (var j = low; j <= high; j++) {
|
||||
range.push(j);
|
||||
}
|
||||
return range;
|
||||
return range(low, high + 1);
|
||||
}
|
||||
return evalValue(exp, scope);
|
||||
}
|
||||
@@ -1096,8 +1059,7 @@
|
||||
};
|
||||
Filter.prototype.render = function (value$$1, scope) {
|
||||
var args = this.args.map(function (arg) { return evalValue(arg, scope); });
|
||||
args.unshift(value$$1);
|
||||
return this.impl.apply(null, args);
|
||||
return this.impl.apply(null, [value$$1].concat(args));
|
||||
};
|
||||
Filter.register = function (name, filter$$1) {
|
||||
Filter.impls[name] = filter$$1;
|
||||
@@ -1112,6 +1074,7 @@
|
||||
var ParseStream = /** @class */ (function () {
|
||||
function ParseStream(tokens, parseToken) {
|
||||
this.handlers = {};
|
||||
this.stopRequested = false;
|
||||
this.tokens = tokens;
|
||||
this.parseToken = parseToken;
|
||||
}
|
||||
@@ -1125,6 +1088,7 @@
|
||||
h(arg);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
ParseStream.prototype.start = function () {
|
||||
this.trigger('start');
|
||||
@@ -1132,8 +1096,7 @@
|
||||
while (!this.stopRequested && (token = this.tokens.shift())) {
|
||||
if (this.trigger('token', token))
|
||||
continue;
|
||||
if (token.type === 'tag' &&
|
||||
this.trigger("tag:" + token.name, token)) {
|
||||
if (token.type === 'tag' && this.trigger("tag:" + token.name, token)) {
|
||||
continue;
|
||||
}
|
||||
var template = this.parseToken(token, this.tokens);
|
||||
@@ -1152,16 +1115,14 @@
|
||||
|
||||
var default_1 = /** @class */ (function () {
|
||||
function default_1(str, strictFilters) {
|
||||
this.filters = [];
|
||||
var match = matchValue(str);
|
||||
assert(match, "illegal value string: " + str);
|
||||
var initial = match[0];
|
||||
this.initial = match[0];
|
||||
str = str.substr(match.index + match[0].length);
|
||||
var filters = [];
|
||||
while ((match = filter.exec(str))) {
|
||||
filters.push([match[0].trim()]);
|
||||
this.filters.push(new Filter(match[0].trim(), strictFilters));
|
||||
}
|
||||
this.initial = initial;
|
||||
this.filters = filters.map(function (str) { return new Filter(str, strictFilters); });
|
||||
}
|
||||
default_1.prototype.value = function (scope) {
|
||||
return this.filters.reduce(function (prev, filter$$1) { return filter$$1.render(prev, scope); }, evalExp(this.initial, scope));
|
||||
@@ -1243,7 +1204,7 @@
|
||||
}());
|
||||
|
||||
var re = new RegExp("(" + identifier.source + ")\\s*=([^]*)");
|
||||
var assign$1 = {
|
||||
var assign = {
|
||||
parse: function (token) {
|
||||
var match = token.args.match(re);
|
||||
assert(match, "illegal token " + token.raw);
|
||||
@@ -1258,12 +1219,6 @@
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
* Call functions in serial until someone resolved.
|
||||
* @param iterable the array to iterate with.
|
||||
* @param iteratee returns a new promise.
|
||||
* The iteratee is invoked with three arguments: (value, index, iterable).
|
||||
*/
|
||||
/*
|
||||
* Call functions in serial until someone rejected.
|
||||
* @param {Array} iterable the array to iterate with.
|
||||
@@ -1271,7 +1226,7 @@
|
||||
* The iteratee is invoked with three arguments: (value, index, iterable).
|
||||
*/
|
||||
function mapSeries(iterable, iteratee) {
|
||||
var ret = Promise.resolve('init');
|
||||
var ret = Promise.resolve(0);
|
||||
var result = [];
|
||||
iterable.forEach(function (item, idx) {
|
||||
ret = ret
|
||||
@@ -1286,107 +1241,109 @@
|
||||
("(?:\\s+" + hash.source + ")*") +
|
||||
"(?:\\s+(reversed))?" +
|
||||
("(?:\\s+" + hash.source + ")*$"));
|
||||
function parse(tagToken, remainTokens) {
|
||||
var _this = this;
|
||||
var match = re$1.exec(tagToken.args);
|
||||
assert(match, "illegal tag: " + tagToken.raw);
|
||||
this.variable = match[1];
|
||||
this.collection = match[2];
|
||||
this.reversed = !!match[3];
|
||||
this.templates = [];
|
||||
this.elseTemplates = [];
|
||||
var p;
|
||||
var stream = this.liquid.parser.parseStream(remainTokens)
|
||||
.on('start', function () { return (p = _this.templates); })
|
||||
.on('tag:else', function () { return (p = _this.elseTemplates); })
|
||||
.on('tag:endfor', function () { return stream.stop(); })
|
||||
.on('template', function (tpl) { return p.push(tpl); })
|
||||
.on('end', function () {
|
||||
throw new Error("tag " + tagToken.raw + " not closed");
|
||||
});
|
||||
stream.start();
|
||||
}
|
||||
function render(scope, hash$$1) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var collection, offset, limit, contexts, html, finished;
|
||||
var For = {
|
||||
type: 'block',
|
||||
parse: function (tagToken, remainTokens) {
|
||||
var _this = this;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
collection = evalExp(this.collection, scope);
|
||||
if (!isArray(collection)) {
|
||||
if (isString(collection) && collection.length > 0) {
|
||||
collection = [collection];
|
||||
}
|
||||
else if (isObject(collection)) {
|
||||
collection = Object.keys(collection).map(function (key) { return [key, collection[key]]; });
|
||||
}
|
||||
}
|
||||
if (!isArray(collection) || !collection.length) {
|
||||
return [2 /*return*/, this.liquid.renderer.renderTemplates(this.elseTemplates, scope)];
|
||||
}
|
||||
offset = hash$$1.offset || 0;
|
||||
limit = (hash$$1.limit === undefined) ? collection.length : hash$$1.limit;
|
||||
collection = collection.slice(offset, offset + limit);
|
||||
if (this.reversed)
|
||||
collection.reverse();
|
||||
contexts = collection.map(function (item, i) {
|
||||
var ctx = {};
|
||||
ctx[_this.variable] = item;
|
||||
ctx['forloop'] = {
|
||||
first: i === 0,
|
||||
index: i + 1,
|
||||
index0: i,
|
||||
last: i === collection.length - 1,
|
||||
length: collection.length,
|
||||
rindex: collection.length - i,
|
||||
rindex0: collection.length - i - 1
|
||||
};
|
||||
return ctx;
|
||||
});
|
||||
html = '';
|
||||
finished = false;
|
||||
return [4 /*yield*/, mapSeries(contexts, function (context) { return __awaiter(_this, void 0, void 0, function () {
|
||||
var _a, e_1;
|
||||
return __generator(this, function (_b) {
|
||||
switch (_b.label) {
|
||||
case 0:
|
||||
if (finished)
|
||||
return [2 /*return*/];
|
||||
scope.push(context);
|
||||
_b.label = 1;
|
||||
case 1:
|
||||
_b.trys.push([1, 3, , 4]);
|
||||
_a = html;
|
||||
return [4 /*yield*/, this.liquid.renderer.renderTemplates(this.templates, scope)];
|
||||
case 2:
|
||||
html = _a + _b.sent();
|
||||
return [3 /*break*/, 4];
|
||||
case 3:
|
||||
e_1 = _b.sent();
|
||||
if (e_1 instanceof RenderBreakError) {
|
||||
html += e_1.resolvedHTML;
|
||||
if (e_1.message === 'break') {
|
||||
finished = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
throw e_1;
|
||||
return [3 /*break*/, 4];
|
||||
case 4:
|
||||
scope.pop(context);
|
||||
return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
}); })];
|
||||
case 1:
|
||||
_a.sent();
|
||||
return [2 /*return*/, html];
|
||||
}
|
||||
var match = re$1.exec(tagToken.args);
|
||||
assert(match, "illegal tag: " + tagToken.raw);
|
||||
this.variable = match[1];
|
||||
this.collection = match[2];
|
||||
this.reversed = !!match[3];
|
||||
this.templates = [];
|
||||
this.elseTemplates = [];
|
||||
var p;
|
||||
var stream = this.liquid.parser.parseStream(remainTokens)
|
||||
.on('start', function () { return (p = _this.templates); })
|
||||
.on('tag:else', function () { return (p = _this.elseTemplates); })
|
||||
.on('tag:endfor', function () { return stream.stop(); })
|
||||
.on('template', function (tpl) { return p.push(tpl); })
|
||||
.on('end', function () {
|
||||
throw new Error("tag " + tagToken.raw + " not closed");
|
||||
});
|
||||
});
|
||||
}
|
||||
var For = { parse: parse, render: render };
|
||||
stream.start();
|
||||
},
|
||||
render: function (scope, hash$$1) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var collection, offset, limit, contexts, html, finished;
|
||||
var _this = this;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
collection = evalExp(this.collection, scope);
|
||||
if (!isArray(collection)) {
|
||||
if (isString(collection) && collection.length > 0) {
|
||||
collection = [collection];
|
||||
}
|
||||
else if (isObject(collection)) {
|
||||
collection = Object.keys(collection).map(function (key) { return [key, collection[key]]; });
|
||||
}
|
||||
}
|
||||
if (!isArray(collection) || !collection.length) {
|
||||
return [2 /*return*/, this.liquid.renderer.renderTemplates(this.elseTemplates, scope)];
|
||||
}
|
||||
offset = hash$$1.offset || 0;
|
||||
limit = (hash$$1.limit === undefined) ? collection.length : hash$$1.limit;
|
||||
collection = collection.slice(offset, offset + limit);
|
||||
if (this.reversed)
|
||||
collection.reverse();
|
||||
contexts = collection.map(function (item, i) {
|
||||
var ctx = {};
|
||||
ctx[_this.variable] = item;
|
||||
ctx['forloop'] = {
|
||||
first: i === 0,
|
||||
index: i + 1,
|
||||
index0: i,
|
||||
last: i === collection.length - 1,
|
||||
length: collection.length,
|
||||
rindex: collection.length - i,
|
||||
rindex0: collection.length - i - 1
|
||||
};
|
||||
return ctx;
|
||||
});
|
||||
html = '';
|
||||
finished = false;
|
||||
return [4 /*yield*/, mapSeries(contexts, function (context) { return __awaiter(_this, void 0, void 0, function () {
|
||||
var _a, e_1;
|
||||
return __generator(this, function (_b) {
|
||||
switch (_b.label) {
|
||||
case 0:
|
||||
if (finished)
|
||||
return [2 /*return*/];
|
||||
scope.push(context);
|
||||
_b.label = 1;
|
||||
case 1:
|
||||
_b.trys.push([1, 3, , 4]);
|
||||
_a = html;
|
||||
return [4 /*yield*/, this.liquid.renderer.renderTemplates(this.templates, scope)];
|
||||
case 2:
|
||||
html = _a + _b.sent();
|
||||
return [3 /*break*/, 4];
|
||||
case 3:
|
||||
e_1 = _b.sent();
|
||||
if (e_1.name === 'RenderBreakError') {
|
||||
html += e_1.resolvedHTML;
|
||||
if (e_1.message === 'break') {
|
||||
finished = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
throw e_1;
|
||||
return [3 /*break*/, 4];
|
||||
case 4:
|
||||
scope.pop(context);
|
||||
return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
}); })];
|
||||
case 1:
|
||||
_a.sent();
|
||||
return [2 /*return*/, html];
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
var re$2 = new RegExp("(" + identifier.source + ")");
|
||||
var capture = {
|
||||
@@ -1573,7 +1530,7 @@
|
||||
render: function (scope) {
|
||||
var group = evalValue(this.group, scope);
|
||||
var fingerprint = "cycle:" + group + ":" + this.candidates.join(',');
|
||||
var groups = scope.opts.groups = scope.opts.groups || {};
|
||||
var groups = scope.groups;
|
||||
var idx = groups[fingerprint];
|
||||
if (idx === undefined) {
|
||||
idx = groups[fingerprint] = 0;
|
||||
@@ -1793,6 +1750,7 @@
|
||||
ctx[_this.variable] = item;
|
||||
return ctx;
|
||||
});
|
||||
row = 0;
|
||||
html = '';
|
||||
return [4 /*yield*/, mapSeries(contexts, function (context, idx) { return __awaiter(_this, void 0, void 0, function () {
|
||||
var col, _a;
|
||||
@@ -1879,7 +1837,7 @@
|
||||
};
|
||||
|
||||
var tags = {
|
||||
assign: assign$1, 'for': For, capture: capture, 'case': Case, comment: comment, include: include, decrement: decrement, increment: increment, cycle: cycle, 'if': If, layout: layout, block: block, raw: raw, tablerow: tablerow, unless: unless, 'break': Break, 'continue': Continue
|
||||
assign: assign, 'for': For, capture: capture, 'case': Case, comment: comment, include: include, decrement: decrement, increment: increment, cycle: cycle, 'if': If, layout: layout, block: block, raw: raw, tablerow: tablerow, unless: unless, 'break': Break, 'continue': Continue
|
||||
};
|
||||
|
||||
var escapeMap = {
|
||||
@@ -1906,14 +1864,13 @@
|
||||
'escape': escape,
|
||||
'escape_once': function (str) { return escape(unescape(str)); },
|
||||
'newline_to_br': function (v) { return v.replace(/\n/g, '<br />'); },
|
||||
'strip_html': function (v) { return String(v).replace(/<script.*?<\/script>|<!--.*?-->|<style.*?<\/style>|<.*?>/g, ''); }
|
||||
'strip_html': function (v) { return v.replace(/<script.*?<\/script>|<!--.*?-->|<style.*?<\/style>|<.*?>/g, ''); }
|
||||
};
|
||||
|
||||
var str = {
|
||||
'append': function (v, arg) { return v + arg; },
|
||||
'prepend': function (v, arg) { return arg + v; },
|
||||
'capitalize': function (str) { return String(str).charAt(0).toUpperCase() + str.slice(1); },
|
||||
'concat': function (v, arg) { return Array.prototype.concat.call(v, arg); },
|
||||
'lstrip': function (v) { return String(v).replace(/^\s+/, ''); },
|
||||
'downcase': function (v) { return v.toLowerCase(); },
|
||||
'upcase': function (str) { return String(str).toUpperCase(); },
|
||||
@@ -1928,19 +1885,19 @@
|
||||
'strip': function (v) { return String(v).trim(); },
|
||||
'strip_newlines': function (v) { return String(v).replace(/\n/g, ''); },
|
||||
'truncate': function (v, l, o) {
|
||||
if (l === void 0) { l = 50; }
|
||||
if (o === void 0) { o = '...'; }
|
||||
v = String(v);
|
||||
o = (o === undefined) ? '...' : o;
|
||||
l = l || 16;
|
||||
if (v.length <= l)
|
||||
return v;
|
||||
return v.substr(0, l - o.length) + o;
|
||||
},
|
||||
'truncatewords': function (v, l, o) {
|
||||
if (o === undefined)
|
||||
o = '...';
|
||||
var arr = v.split(' ');
|
||||
if (l === void 0) { l = 15; }
|
||||
if (o === void 0) { o = '...'; }
|
||||
var arr = v.split(/\s+/);
|
||||
var ret = arr.slice(0, l).join(' ');
|
||||
if (arr.length > l)
|
||||
if (arr.length >= l)
|
||||
ret += o;
|
||||
return ret;
|
||||
}
|
||||
@@ -1954,7 +1911,8 @@
|
||||
'minus': bindFixed(function (v, arg) { return v - arg; }),
|
||||
'modulo': bindFixed(function (v, arg) { return v % arg; }),
|
||||
'round': function (v, arg) {
|
||||
var amp = Math.pow(10, arg || 0);
|
||||
if (arg === void 0) { arg = 0; }
|
||||
var amp = Math.pow(10, arg);
|
||||
return Math.round(v * amp) / amp;
|
||||
},
|
||||
'plus': bindFixed(function (v, arg) { return Number(v) + Number(arg); }),
|
||||
@@ -1984,6 +1942,7 @@
|
||||
'reverse': function (v) { return v.reverse(); },
|
||||
'sort': function (v, arg) { return v.sort(arg); },
|
||||
'size': function (v) { return v.length; },
|
||||
'concat': function (v, arg) { return Array.prototype.concat.call(v, arg); },
|
||||
'slice': function (v, begin, length) {
|
||||
if (length === undefined)
|
||||
length = 1;
|
||||
@@ -1992,10 +1951,9 @@
|
||||
'uniq': function (arr) {
|
||||
var u = {};
|
||||
return (arr || []).filter(function (val) {
|
||||
if (u.hasOwnProperty(val)) {
|
||||
if (u.hasOwnProperty(String(val)))
|
||||
return false;
|
||||
}
|
||||
u[val] = true;
|
||||
u[String(val)] = true;
|
||||
return true;
|
||||
});
|
||||
}
|
||||
@@ -2167,7 +2125,7 @@
|
||||
// Add the format code
|
||||
var ch = results[0].charAt(1);
|
||||
var func = formatCodes[ch];
|
||||
output += func ? func.call(this, d) : '%' + ch;
|
||||
output += func ? func(d) : '%' + ch;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2197,10 +2155,8 @@
|
||||
function Liquid(opts) {
|
||||
if (opts === void 0) { opts = {}; }
|
||||
var _this = this;
|
||||
this.cache = {};
|
||||
this.options = applyDefault(normalize(opts));
|
||||
if (this.options.cache) {
|
||||
this.cache = {};
|
||||
}
|
||||
this.parser = new Parser(this);
|
||||
this.renderer = new Render();
|
||||
this.tokenizer = new Tokenizer(this.options);
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
@@ -2,5 +2,5 @@ import Token from './token';
|
||||
export default class DelimitedToken extends Token {
|
||||
trimLeft: boolean;
|
||||
trimRight: boolean;
|
||||
constructor(raw: any, value: any, pos: any, input: any, file: any, line: any);
|
||||
constructor(raw: string, value: string, input: string, line: number, pos: number, file?: string);
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
import Token from './token';
|
||||
export default class HTMLToken extends Token {
|
||||
constructor(str: any, begin: any, input: any, file: any, line: any);
|
||||
constructor(str: string, input: string, line: number, col: number, file?: string);
|
||||
}
|
||||
|
||||
Vendored
+6
-6
@@ -27,9 +27,9 @@ export declare const filter: RegExp;
|
||||
export declare const filterCapture: RegExp;
|
||||
export declare const filterLine: RegExp;
|
||||
export declare const operators: RegExp[];
|
||||
export declare function isInteger(str: any): boolean;
|
||||
export declare function isLiteral(str: any): boolean;
|
||||
export declare function isRange(str: any): boolean;
|
||||
export declare function isVariable(str: any): boolean;
|
||||
export declare function matchValue(str: any): RegExpExecArray;
|
||||
export declare function parseLiteral(str: any): any;
|
||||
export declare function isInteger(str: string): boolean;
|
||||
export declare function isLiteral(str: string): boolean;
|
||||
export declare function isRange(str: string): boolean;
|
||||
export declare function isVariable(str: string): boolean;
|
||||
export declare function matchValue(str: string): RegExpExecArray | null;
|
||||
export declare function parseLiteral(str: string): string | number | boolean;
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
import DelimitedToken from './delimited-token';
|
||||
export default class OutputToken extends DelimitedToken {
|
||||
constructor(raw: any, value: any, pos: any, input: any, file: any, line: any);
|
||||
constructor(raw: string, value: string, input: string, line: number, pos: number, file?: string);
|
||||
}
|
||||
|
||||
Vendored
+4
-5
@@ -1,15 +1,14 @@
|
||||
import Token from 'src/parser/token';
|
||||
import ITemplate from 'src/template/itemplate';
|
||||
declare type parseToken = (token: Token, remainTokens: Array<Token>) => ITemplate;
|
||||
declare type eventHandler = ((arg?: Token | ITemplate) => void);
|
||||
declare type ParseToken = ((token: Token, remainTokens: Array<Token>) => ITemplate);
|
||||
export default class ParseStream {
|
||||
private tokens;
|
||||
private handlers;
|
||||
private stopRequested;
|
||||
private parseToken;
|
||||
constructor(tokens: Array<Token>, parseToken: parseToken);
|
||||
on(name: string, cb: eventHandler): this;
|
||||
trigger(event: string, arg?: Token | ITemplate): boolean;
|
||||
constructor(tokens: Array<Token>, parseToken: ParseToken);
|
||||
on<T extends ITemplate | Token | undefined>(name: string, cb: (arg: T) => void): ParseStream;
|
||||
trigger<T extends Token | ITemplate>(event: string, arg?: T): boolean;
|
||||
start(): this;
|
||||
stop(): this;
|
||||
}
|
||||
|
||||
Vendored
+2
-1
@@ -4,10 +4,11 @@ import Token from './token';
|
||||
import Tag from 'src/template/tag/tag';
|
||||
import Output from 'src/template/output';
|
||||
import HTML from 'src/template/html';
|
||||
import ITemplate from 'src/template/itemplate';
|
||||
export default class Parser {
|
||||
liquid: Liquid;
|
||||
constructor(liquid: Liquid);
|
||||
parse(tokens: Array<Token>): any[];
|
||||
parse(tokens: Array<Token>): ITemplate[];
|
||||
parseToken(token: Token, remainTokens: Array<Token>): Tag | Output | HTML;
|
||||
parseStream(tokens: Array<Token>): ParseStream;
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -2,5 +2,5 @@ import DelimitedToken from './delimited-token';
|
||||
export default class TagToken extends DelimitedToken {
|
||||
name: string;
|
||||
args: string;
|
||||
constructor(raw: any, value: any, pos: any, input: any, file: any, line: any);
|
||||
constructor(raw: string, value: string, input: string, line: number, pos: number, file?: string);
|
||||
}
|
||||
|
||||
Vendored
+2
-2
@@ -4,7 +4,7 @@ export default class Token {
|
||||
col: number;
|
||||
raw: string;
|
||||
input: string;
|
||||
file: string;
|
||||
file?: string;
|
||||
value: string;
|
||||
constructor(raw: any, col: any, input: any, file: any, line: any);
|
||||
constructor(raw: string, input: string, line: number, col: number, file?: string);
|
||||
}
|
||||
|
||||
Vendored
+2
-1
@@ -1,6 +1,7 @@
|
||||
import Token from './token';
|
||||
import { NormalizedFullOptions } from '../liquid-options';
|
||||
export default class Tokenizer {
|
||||
options: NormalizedFullOptions;
|
||||
constructor(options?: NormalizedFullOptions);
|
||||
tokenize(input: string, file?: string): any[];
|
||||
tokenize(input: string, file?: string): Token[];
|
||||
}
|
||||
|
||||
Vendored
+3
-1
@@ -1,3 +1,5 @@
|
||||
import Scope from 'src/scope/scope';
|
||||
import ITemplate from 'src/template/itemplate';
|
||||
export default class Render {
|
||||
renderTemplates(templates: any, scope: any): Promise<string>;
|
||||
renderTemplates(templates: ITemplate[], scope: Scope): Promise<string>;
|
||||
}
|
||||
|
||||
Vendored
+3
-2
@@ -1,4 +1,5 @@
|
||||
export declare function evalExp(exp: any, scope: any): any;
|
||||
export declare function evalValue(str: any, scope: any): any;
|
||||
import Scope from 'src/scope/scope';
|
||||
export declare function evalExp(exp: string, scope: Scope): any;
|
||||
export declare function evalValue(str: string, scope: Scope): any;
|
||||
export declare function isTruthy(val: any): boolean;
|
||||
export declare function isFalsy(val: any): boolean;
|
||||
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
export default interface IContext {
|
||||
[key: string]: any;
|
||||
liquid_method_missing?: (key: string) => any;
|
||||
}
|
||||
Vendored
+10
-6
@@ -1,18 +1,22 @@
|
||||
import { NormalizedFullOptions } from '../liquid-options';
|
||||
import BlockMode from './block-mode';
|
||||
import IContext from './icontext';
|
||||
export default class Scope {
|
||||
opts: NormalizedFullOptions;
|
||||
contexts: Array<object>;
|
||||
contexts: Array<IContext>;
|
||||
blocks: object;
|
||||
groups: {
|
||||
[key: string]: number;
|
||||
};
|
||||
blockMode: BlockMode;
|
||||
constructor(ctx?: object, opts?: NormalizedFullOptions);
|
||||
getAll(): object;
|
||||
getAll(): IContext;
|
||||
get(path: string): any;
|
||||
set(path: string, v: any): void;
|
||||
unshift(ctx: object): number;
|
||||
push(ctx: object): number;
|
||||
pop(ctx?: object): object;
|
||||
findContextFor(key: string, filter?: ((conttext: object) => boolean)): object;
|
||||
readProperty(obj: any, key: any): any;
|
||||
propertyAccessSeq(str: any): any[];
|
||||
pop(ctx?: object): object | undefined;
|
||||
findContextFor(key: string, filter?: ((conttext: object) => boolean)): IContext | null;
|
||||
private readProperty;
|
||||
propertyAccessSeq(str: string): string[];
|
||||
}
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
export declare type FilterImpl = (value: any, ...args: any[]) => any;
|
||||
Vendored
+13
@@ -0,0 +1,13 @@
|
||||
import Scope from 'src/scope/scope';
|
||||
import { FilterImpl } from './filter-impl';
|
||||
export default class Filter {
|
||||
name: string;
|
||||
impl: FilterImpl;
|
||||
args: string[];
|
||||
private static impls;
|
||||
constructor(str: string, strictFilters?: boolean);
|
||||
parseArgs(argList: string): string[];
|
||||
render(value: any, scope: Scope): any;
|
||||
static register(name: string, filter: FilterImpl): void;
|
||||
static clear(): void;
|
||||
}
|
||||
Vendored
+3
-3
@@ -1,8 +1,8 @@
|
||||
import Template from 'src/template/template';
|
||||
import ITemplate from 'src/template/itemplate';
|
||||
import Token from 'src/parser/token';
|
||||
export default class extends Template implements ITemplate {
|
||||
import HTMLToken from 'src/parser/html-token';
|
||||
export default class extends Template<HTMLToken> implements ITemplate {
|
||||
str: string;
|
||||
constructor(token: Token);
|
||||
constructor(token: HTMLToken);
|
||||
render(): Promise<string>;
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -3,7 +3,7 @@ import Template from 'src/template/template';
|
||||
import ITemplate from 'src/template/itemplate';
|
||||
import Scope from 'src/scope/scope';
|
||||
import OutputToken from 'src/parser/output-token';
|
||||
export default class Output extends Template implements ITemplate {
|
||||
export default class Output extends Template<OutputToken> implements ITemplate {
|
||||
value: Value;
|
||||
constructor(token: OutputToken, strictFilters?: boolean);
|
||||
render(scope: Scope): Promise<string>;
|
||||
|
||||
Vendored
+18
@@ -0,0 +1,18 @@
|
||||
import Scope from 'src/scope/scope';
|
||||
import ITagImplOptions from './itag-impl-options';
|
||||
import Liquid from 'src/liquid';
|
||||
import Template from 'src/template/template';
|
||||
import ITemplate from 'src/template/itemplate';
|
||||
import TagToken from 'src/parser/tag-token';
|
||||
import Token from 'src/parser/token';
|
||||
export default class Tag extends Template<TagToken> implements ITemplate {
|
||||
name: string;
|
||||
private impl;
|
||||
static impls: {
|
||||
[key: string]: ITagImplOptions;
|
||||
};
|
||||
constructor(token: TagToken, tokens: Token[], liquid: Liquid);
|
||||
render(scope: Scope): Promise<string>;
|
||||
static register(name: string, tag: ITagImplOptions): void;
|
||||
static clear(): void;
|
||||
}
|
||||
Vendored
+2
-1
@@ -1,3 +1,4 @@
|
||||
import Scope from 'src/scope/scope';
|
||||
/**
|
||||
* Key-Value Pairs Representing Tag Arguments
|
||||
* Example:
|
||||
@@ -6,5 +7,5 @@
|
||||
*/
|
||||
export default class Hash {
|
||||
[key: string]: any;
|
||||
constructor(markup: any, scope: any);
|
||||
constructor(markup: string, scope: Scope);
|
||||
}
|
||||
|
||||
Vendored
+1
@@ -2,4 +2,5 @@ import Liquid from 'src/liquid';
|
||||
import ITagImplOptions from './itag-impl-options';
|
||||
export default interface ITagImpl extends ITagImplOptions {
|
||||
liquid: Liquid;
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
Vendored
+1
-2
@@ -5,9 +5,8 @@ import Template from 'src/template/template';
|
||||
import ITemplate from 'src/template/itemplate';
|
||||
import TagToken from 'src/parser/tag-token';
|
||||
import Token from 'src/parser/token';
|
||||
export default class Tag extends Template implements ITemplate {
|
||||
export default class Tag extends Template<TagToken> implements ITemplate {
|
||||
name: string;
|
||||
token: TagToken;
|
||||
private impl;
|
||||
static impls: {
|
||||
[key: string]: ITagImplOptions;
|
||||
|
||||
Vendored
+3
-4
@@ -1,5 +1,4 @@
|
||||
import Token from 'src/parser/token';
|
||||
export default class Template {
|
||||
token: Token;
|
||||
constructor(token: any);
|
||||
export default abstract class Template<T> {
|
||||
token: T;
|
||||
constructor(token: T);
|
||||
}
|
||||
|
||||
Vendored
+2
-1
@@ -1,7 +1,8 @@
|
||||
import Filter from './filter/filter';
|
||||
import Scope from 'src/scope/scope';
|
||||
export default class {
|
||||
initial: any;
|
||||
filters: Array<any>;
|
||||
filters: Array<Filter>;
|
||||
constructor(str: string, strictFilters?: boolean);
|
||||
value(scope: Scope): any;
|
||||
}
|
||||
|
||||
Vendored
+12
-17
@@ -1,30 +1,25 @@
|
||||
declare abstract class LiquidError {
|
||||
name: string;
|
||||
message: string;
|
||||
stack: string;
|
||||
private file;
|
||||
private input;
|
||||
import Token from 'src/parser/token';
|
||||
import ITemplate from 'src/template/itemplate';
|
||||
declare abstract class LiquidError extends Error {
|
||||
private token;
|
||||
private originalError;
|
||||
constructor(err: any, token: any);
|
||||
captureStackTrace(obj: any): void;
|
||||
constructor(err: Error, token: Token);
|
||||
protected update(): void;
|
||||
}
|
||||
export declare class TokenizationError extends LiquidError {
|
||||
constructor(message: any, token: any);
|
||||
constructor(message: string, token: Token);
|
||||
}
|
||||
export declare class ParseError extends LiquidError {
|
||||
constructor(err: any, token: any);
|
||||
constructor(err: Error, token: Token);
|
||||
}
|
||||
export declare class RenderError extends LiquidError {
|
||||
constructor(err: any, tpl: any);
|
||||
constructor(err: Error, tpl: ITemplate);
|
||||
}
|
||||
export declare class RenderBreakError {
|
||||
message: string;
|
||||
export declare class RenderBreakError extends Error {
|
||||
resolvedHTML: string;
|
||||
constructor(message: any);
|
||||
constructor(message: string);
|
||||
}
|
||||
export declare class AssertionError {
|
||||
message: string;
|
||||
constructor(message: any);
|
||||
export declare class AssertionError extends Error {
|
||||
constructor(message: string);
|
||||
}
|
||||
export {};
|
||||
|
||||
Vendored
+1
-2
@@ -1,2 +1 @@
|
||||
export declare function anySeries(iterable: any, iteratee: any): Promise<any>;
|
||||
export declare function mapSeries(iterable: any, iteratee: any): Promise<any[]>;
|
||||
export declare function mapSeries<T1, T2>(iterable: T1[], iteratee: (item: T1, idx: number, iterable: T1[]) => Promise<T2> | T2): Promise<T2[]>;
|
||||
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
export default function (d: any, format: any): string;
|
||||
export default function (d: Date, format: string): string;
|
||||
|
||||
Vendored
+12
-6
@@ -1,15 +1,21 @@
|
||||
export declare function isString(value: any): boolean;
|
||||
export declare function isFunction(value: any): boolean;
|
||||
export declare function promisify(fn: any): (...args: any[]) => Promise<{}>;
|
||||
export declare function promisify<T1, T2>(fn: (arg1: T1, cb: (err: Error | null, result: T2) => void) => void): (arg1: T1) => Promise<T2>;
|
||||
export declare function promisify<T1, T2, T3>(fn: (arg1: T1, arg2: T2, cb: (err: Error | null, result: T3) => void) => void): (arg1: T1, arg2: T2) => Promise<T3>;
|
||||
export declare function stringify(value: any): string;
|
||||
export declare function create<T1 extends object, T2 extends T1 = T1>(proto: T1): T2;
|
||||
export declare function isNil(value: any): boolean;
|
||||
export declare function isArray(value: any): boolean;
|
||||
export declare function isError(value: any): boolean;
|
||||
export declare function forOwn(object: any, iteratee: ((val: any, key: string, obj: object) => boolean | void)): any;
|
||||
export declare function assign(obj: object, ...srcs: object[]): object;
|
||||
export declare function last(arr: any[]): any;
|
||||
export declare function uniq(arr: any[]): any[];
|
||||
export declare function forOwn<T>(object: {
|
||||
[key: string]: T;
|
||||
} | undefined, iteratee: ((val: T, key: string, obj: {
|
||||
[key: string]: T;
|
||||
}) => boolean | void)): {
|
||||
[key: string]: T;
|
||||
};
|
||||
export declare function last<T>(arr: T[]): T;
|
||||
export declare function last(arr: string): string;
|
||||
export declare function isObject(value: any): boolean;
|
||||
export declare function range(start: number, stop?: number, step?: number): any[];
|
||||
export declare function range(start: number, stop?: number, step?: number): number[];
|
||||
export declare function padStart(str: any, length: number, ch?: string): any;
|
||||
|
||||
Generated
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "liquidjs",
|
||||
"version": "7.2.0",
|
||||
"version": "7.2.1",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "liquidjs",
|
||||
"version": "7.2.0",
|
||||
"version": "7.2.1",
|
||||
"description": "Liquid template engine by pure JavaScript: compatible to shopify, easy to extend.",
|
||||
"main": "dist/liquid.common.js",
|
||||
"types": "dist/liquid.d.ts",
|
||||
|
||||
Reference in New Issue
Block a user