mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-29 07:05:13 -07:00
chore(release): 7.2.0 [skip ci]
# [7.2.0](https://github.com/harttle/liquidjs/compare/v7.1.0...v7.2.0) (2019-02-20)
### Features
* override output/tag delimiter, fixes [#54](https://github.com/harttle/liquidjs/issues/54) ([d20a043](https://github.com/harttle/liquidjs/commit/d20a043))
This commit is contained in:
@@ -1,3 +1,10 @@
|
|||||||
|
# [7.2.0](https://github.com/harttle/liquidjs/compare/v7.1.0...v7.2.0) (2019-02-20)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* override output/tag delimiter, fixes [#54](https://github.com/harttle/liquidjs/issues/54) ([d20a043](https://github.com/harttle/liquidjs/commit/d20a043))
|
||||||
|
|
||||||
# [7.1.0](https://github.com/harttle/liquidjs/compare/v7.0.2...v7.1.0) (2019-02-20)
|
# [7.1.0](https://github.com/harttle/liquidjs/compare/v7.0.2...v7.1.0) (2019-02-20)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Vendored
+24
-5
@@ -15,15 +15,34 @@ export interface LiquidOptions {
|
|||||||
trim_tag_right?: boolean;
|
trim_tag_right?: boolean;
|
||||||
/** `trim_tag_left` is similar to `trim_tag_right`, whereas the `\n` is exclusive. Defaults to `false`. See Whitespace Control for details. */
|
/** `trim_tag_left` is similar to `trim_tag_right`, whereas the `\n` is exclusive. Defaults to `false`. See Whitespace Control for details. */
|
||||||
trim_tag_left?: boolean;
|
trim_tag_left?: boolean;
|
||||||
/** ``trim_value_right` is used to strip blank characters (including ` `, `\t`, and `\r`) from the right of values (`{{ }}`) until `\n` (inclusive). Defaults to `false`. */
|
/** ``trim_output_right` is used to strip blank characters (including ` `, `\t`, and `\r`) from the right of values (`{{ }}`) until `\n` (inclusive). Defaults to `false`. */
|
||||||
trim_value_right?: boolean;
|
trim_output_right?: boolean;
|
||||||
/** `trim_value_left` is similar to `trim_value_right`, whereas the `\n` is exclusive. Defaults to `false`. See Whitespace Control for details. */
|
/** `trim_output_left` is similar to `trim_output_right`, whereas the `\n` is exclusive. Defaults to `false`. See Whitespace Control for details. */
|
||||||
trim_value_left?: boolean;
|
trim_output_left?: boolean;
|
||||||
|
/** `tag_delimiter_left` and `tag_delimiter_right` are used to override the delimiter for liquid tags **/
|
||||||
|
tag_delimiter_left?: string;
|
||||||
|
tag_delimiter_right?: string;
|
||||||
|
/** `output_delimiter_left` and `output_delimiter_right` are used to override the delimiter for liquid outputs **/
|
||||||
|
output_delimiter_left?: string;
|
||||||
|
output_delimiter_right?: string;
|
||||||
/** `greedy` is used to specify whether `trim_left`/`trim_right` is greedy. When set to `true`, all consecutive blank characters including `\n` will be trimed regardless of line breaks. Defaults to `true`. */
|
/** `greedy` is used to specify whether `trim_left`/`trim_right` is greedy. When set to `true`, all consecutive blank characters including `\n` will be trimed regardless of line breaks. Defaults to `true`. */
|
||||||
greedy?: boolean;
|
greedy?: boolean;
|
||||||
}
|
}
|
||||||
export interface NormalizedOptions extends LiquidOptions {
|
export interface NormalizedOptions extends LiquidOptions {
|
||||||
root?: string[];
|
root?: string[];
|
||||||
}
|
}
|
||||||
export declare const defaultOptions: NormalizedOptions;
|
export interface NormalizedFullOptions extends NormalizedOptions {
|
||||||
|
root: string[];
|
||||||
|
extname: string;
|
||||||
|
cache: boolean;
|
||||||
|
dynamicPartials: boolean;
|
||||||
|
strict_filters: boolean;
|
||||||
|
strict_variables: boolean;
|
||||||
|
trim_tag_right: boolean;
|
||||||
|
trim_tag_left: boolean;
|
||||||
|
trim_output_right: boolean;
|
||||||
|
trim_output_left: boolean;
|
||||||
|
greedy: boolean;
|
||||||
|
}
|
||||||
export declare function normalize(options: LiquidOptions): NormalizedOptions;
|
export declare function normalize(options: LiquidOptions): NormalizedOptions;
|
||||||
|
export declare function applyDefault(options: NormalizedOptions): NormalizedFullOptions;
|
||||||
|
|||||||
Vendored
+53
-33
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* liquidjs@7.1.0, https://github.com/harttle/liquidjs
|
* liquidjs@7.2.0, https://github.com/harttle/liquidjs
|
||||||
* (c) 2016-2019 harttle
|
* (c) 2016-2019 harttle
|
||||||
* Released under the MIT License.
|
* Released under the MIT License.
|
||||||
*/
|
*/
|
||||||
@@ -413,6 +413,7 @@ function assert (predicate, message) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* eslint-disable camelcase */
|
||||||
var defaultOptions = {
|
var defaultOptions = {
|
||||||
root: ['.'],
|
root: ['.'],
|
||||||
cache: false,
|
cache: false,
|
||||||
@@ -420,9 +421,13 @@ var defaultOptions = {
|
|||||||
dynamicPartials: true,
|
dynamicPartials: true,
|
||||||
trim_tag_right: false,
|
trim_tag_right: false,
|
||||||
trim_tag_left: false,
|
trim_tag_left: false,
|
||||||
trim_value_right: false,
|
trim_output_right: false,
|
||||||
trim_value_left: false,
|
trim_output_left: false,
|
||||||
greedy: true,
|
greedy: true,
|
||||||
|
tag_delimiter_left: '{%',
|
||||||
|
tag_delimiter_right: '%}',
|
||||||
|
output_delimiter_left: '{{',
|
||||||
|
output_delimiter_right: '}}',
|
||||||
strict_filters: false,
|
strict_filters: false,
|
||||||
strict_variables: false
|
strict_variables: false
|
||||||
};
|
};
|
||||||
@@ -433,6 +438,9 @@ function normalize(options) {
|
|||||||
}
|
}
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
function applyDefault(options) {
|
||||||
|
return __assign({}, defaultOptions, options);
|
||||||
|
}
|
||||||
function normalizeStringArray(value) {
|
function normalizeStringArray(value) {
|
||||||
if (isArray(value))
|
if (isArray(value))
|
||||||
return value;
|
return value;
|
||||||
@@ -453,10 +461,9 @@ var BlockMode$1 = BlockMode;
|
|||||||
var Scope = /** @class */ (function () {
|
var Scope = /** @class */ (function () {
|
||||||
function Scope(ctx, opts) {
|
function Scope(ctx, opts) {
|
||||||
if (ctx === void 0) { ctx = {}; }
|
if (ctx === void 0) { ctx = {}; }
|
||||||
if (opts === void 0) { opts = defaultOptions; }
|
|
||||||
this.blocks = {};
|
this.blocks = {};
|
||||||
this.blockMode = BlockMode$1.OUTPUT;
|
this.blockMode = BlockMode$1.OUTPUT;
|
||||||
this.opts = __assign({}, defaultOptions, opts);
|
this.opts = applyDefault(opts);
|
||||||
this.contexts = [ctx || {}];
|
this.contexts = [ctx || {}];
|
||||||
}
|
}
|
||||||
Scope.prototype.getAll = function () {
|
Scope.prototype.getAll = function () {
|
||||||
@@ -693,7 +700,7 @@ function shouldTrimLeft(token, inRaw, options) {
|
|||||||
if (token.type === 'tag')
|
if (token.type === 'tag')
|
||||||
return token.trimLeft || options.trim_tag_left;
|
return token.trimLeft || options.trim_tag_left;
|
||||||
if (token.type === 'output')
|
if (token.type === 'output')
|
||||||
return token.trimLeft || options.trim_value_left;
|
return token.trimLeft || options.trim_output_left;
|
||||||
}
|
}
|
||||||
function shouldTrimRight(token, inRaw, options) {
|
function shouldTrimRight(token, inRaw, options) {
|
||||||
if (inRaw)
|
if (inRaw)
|
||||||
@@ -701,7 +708,7 @@ function shouldTrimRight(token, inRaw, options) {
|
|||||||
if (token.type === 'tag')
|
if (token.type === 'tag')
|
||||||
return token.trimRight || options.trim_tag_right;
|
return token.trimRight || options.trim_tag_right;
|
||||||
if (token.type === 'output')
|
if (token.type === 'output')
|
||||||
return token.trimRight || options.trim_value_right;
|
return token.trimRight || options.trim_output_right;
|
||||||
}
|
}
|
||||||
function trimLeft(token, greedy) {
|
function trimLeft(token, greedy) {
|
||||||
if (!token || token.type !== 'html')
|
if (!token || token.type !== 'html')
|
||||||
@@ -740,11 +747,13 @@ var HTMLToken = /** @class */ (function (_super) {
|
|||||||
|
|
||||||
var DelimitedToken = /** @class */ (function (_super) {
|
var DelimitedToken = /** @class */ (function (_super) {
|
||||||
__extends(DelimitedToken, _super);
|
__extends(DelimitedToken, _super);
|
||||||
function DelimitedToken(raw, pos, input, file, line) {
|
function DelimitedToken(raw, value, pos, input, file, line) {
|
||||||
var _this = _super.call(this, raw, pos, input, file, line) || this;
|
var _this = _super.call(this, raw, pos, input, file, line) || this;
|
||||||
_this.trimLeft = raw[2] === '-';
|
_this.trimLeft = value[0] === '-';
|
||||||
_this.trimRight = raw[raw.length - 3] === '-';
|
_this.trimRight = value[value.length - 1] === '-';
|
||||||
_this.value = raw.slice(_this.trimLeft ? 3 : 2, _this.trimRight ? -3 : -2).trim();
|
_this.value = value
|
||||||
|
.slice(_this.trimLeft ? 1 : 0, _this.trimRight ? -1 : value.length)
|
||||||
|
.trim();
|
||||||
return _this;
|
return _this;
|
||||||
}
|
}
|
||||||
return DelimitedToken;
|
return DelimitedToken;
|
||||||
@@ -752,8 +761,8 @@ var DelimitedToken = /** @class */ (function (_super) {
|
|||||||
|
|
||||||
var TagToken = /** @class */ (function (_super) {
|
var TagToken = /** @class */ (function (_super) {
|
||||||
__extends(TagToken, _super);
|
__extends(TagToken, _super);
|
||||||
function TagToken(raw, pos, input, file, line) {
|
function TagToken(raw, value$$1, pos, input, file, line) {
|
||||||
var _this = _super.call(this, raw, pos, input, file, line) || this;
|
var _this = _super.call(this, raw, value$$1, pos, input, file, line) || this;
|
||||||
_this.type = 'tag';
|
_this.type = 'tag';
|
||||||
var match = _this.value.match(tagLine);
|
var match = _this.value.match(tagLine);
|
||||||
if (!match) {
|
if (!match) {
|
||||||
@@ -768,8 +777,8 @@ var TagToken = /** @class */ (function (_super) {
|
|||||||
|
|
||||||
var OutputToken = /** @class */ (function (_super) {
|
var OutputToken = /** @class */ (function (_super) {
|
||||||
__extends(OutputToken, _super);
|
__extends(OutputToken, _super);
|
||||||
function OutputToken(raw, pos, input, file, line) {
|
function OutputToken(raw, value, pos, input, file, line) {
|
||||||
var _this = _super.call(this, raw, pos, input, file, line) || this;
|
var _this = _super.call(this, raw, value, pos, input, file, line) || this;
|
||||||
_this.type = 'output';
|
_this.type = 'output';
|
||||||
return _this;
|
return _this;
|
||||||
}
|
}
|
||||||
@@ -784,11 +793,14 @@ var ParseState;
|
|||||||
})(ParseState || (ParseState = {}));
|
})(ParseState || (ParseState = {}));
|
||||||
var Tokenizer = /** @class */ (function () {
|
var Tokenizer = /** @class */ (function () {
|
||||||
function Tokenizer(options) {
|
function Tokenizer(options) {
|
||||||
if (options === void 0) { options = defaultOptions; }
|
this.options = applyDefault(options);
|
||||||
this.options = options;
|
|
||||||
}
|
}
|
||||||
Tokenizer.prototype.tokenize = function (input, file) {
|
Tokenizer.prototype.tokenize = function (input, file) {
|
||||||
var tokens = [];
|
var tokens = [];
|
||||||
|
var tagL = this.options.tag_delimiter_left;
|
||||||
|
var tagR = this.options.tag_delimiter_right;
|
||||||
|
var outputL = this.options.output_delimiter_left;
|
||||||
|
var outputR = this.options.output_delimiter_right;
|
||||||
var p = 0;
|
var p = 0;
|
||||||
var curLine = 1;
|
var curLine = 1;
|
||||||
var state = ParseState.HTML;
|
var state = ParseState.HTML;
|
||||||
@@ -801,33 +813,42 @@ var Tokenizer = /** @class */ (function () {
|
|||||||
curLine++;
|
curLine++;
|
||||||
lineBegin = p + 1;
|
lineBegin = p + 1;
|
||||||
}
|
}
|
||||||
var bin = input.substr(p, 2);
|
|
||||||
if (state === ParseState.HTML) {
|
if (state === ParseState.HTML) {
|
||||||
if (bin === '{{' || bin === '{%') {
|
if (input.substr(p, outputL.length) === outputL) {
|
||||||
if (buffer)
|
if (buffer)
|
||||||
tokens.push(new HTMLToken(buffer, col, input, file, line));
|
tokens.push(new HTMLToken(buffer, col, input, file, line));
|
||||||
buffer = bin;
|
buffer = outputL;
|
||||||
line = curLine;
|
line = curLine;
|
||||||
col = p - lineBegin + 1;
|
col = p - lineBegin + 1;
|
||||||
p += 2;
|
p += outputL.length;
|
||||||
state = bin === '{{' ? ParseState.OUTPUT : ParseState.TAG;
|
state = ParseState.OUTPUT;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else if (input.substr(p, tagL.length) === tagL) {
|
||||||
|
if (buffer)
|
||||||
|
tokens.push(new HTMLToken(buffer, col, input, file, line));
|
||||||
|
buffer = tagL;
|
||||||
|
line = curLine;
|
||||||
|
col = p - lineBegin + 1;
|
||||||
|
p += tagL.length;
|
||||||
|
state = ParseState.TAG;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (state === ParseState.OUTPUT && bin === '}}') {
|
else if (state === ParseState.OUTPUT && input.substr(p, outputR.length) === outputR) {
|
||||||
buffer += '}}';
|
buffer += outputR;
|
||||||
tokens.push(new OutputToken(buffer, col, input, file, line));
|
tokens.push(new OutputToken(buffer, buffer.slice(outputL.length, -outputR.length), col, input, file, line));
|
||||||
p += 2;
|
p += outputR.length;
|
||||||
buffer = '';
|
buffer = '';
|
||||||
line = curLine;
|
line = curLine;
|
||||||
col = p - lineBegin + 1;
|
col = p - lineBegin + 1;
|
||||||
state = ParseState.HTML;
|
state = ParseState.HTML;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (bin === '%}') {
|
else if (input.substr(p, tagR.length) === tagR) {
|
||||||
buffer += '%}';
|
buffer += tagR;
|
||||||
tokens.push(new TagToken(buffer, col, input, file, line));
|
tokens.push(new TagToken(buffer, buffer.slice(tagL.length, -tagR.length), col, input, file, line));
|
||||||
p += 2;
|
p += tagR.length;
|
||||||
buffer = '';
|
buffer = '';
|
||||||
line = curLine;
|
line = curLine;
|
||||||
col = p - lineBegin + 1;
|
col = p - lineBegin + 1;
|
||||||
@@ -2151,11 +2172,10 @@ var Liquid = /** @class */ (function () {
|
|||||||
function Liquid(opts) {
|
function Liquid(opts) {
|
||||||
if (opts === void 0) { opts = {}; }
|
if (opts === void 0) { opts = {}; }
|
||||||
var _this = this;
|
var _this = this;
|
||||||
var options = __assign({}, defaultOptions, normalize(opts));
|
this.options = applyDefault(normalize(opts));
|
||||||
if (options.cache) {
|
if (this.options.cache) {
|
||||||
this.cache = {};
|
this.cache = {};
|
||||||
}
|
}
|
||||||
this.options = options;
|
|
||||||
this.parser = new Parser(this);
|
this.parser = new Parser(this);
|
||||||
this.renderer = new Render();
|
this.renderer = new Render();
|
||||||
this.tokenizer = new Tokenizer(this.options);
|
this.tokenizer = new Tokenizer(this.options);
|
||||||
|
|||||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+2
-2
@@ -3,9 +3,9 @@ import * as Types from './types';
|
|||||||
import ITemplate from './template/itemplate';
|
import ITemplate from './template/itemplate';
|
||||||
import ITagImplOptions from './template/tag/itag-impl-options';
|
import ITagImplOptions from './template/tag/itag-impl-options';
|
||||||
import { isTruthy, isFalsy, evalExp, evalValue } from './render/syntax';
|
import { isTruthy, isFalsy, evalExp, evalValue } from './render/syntax';
|
||||||
import { LiquidOptions, NormalizedOptions } from './liquid-options';
|
import { LiquidOptions, NormalizedFullOptions } from './liquid-options';
|
||||||
export default class Liquid {
|
export default class Liquid {
|
||||||
options: NormalizedOptions;
|
options: NormalizedFullOptions;
|
||||||
private cache;
|
private cache;
|
||||||
private parser;
|
private parser;
|
||||||
private renderer;
|
private renderer;
|
||||||
|
|||||||
Vendored
+53
-33
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* liquidjs@7.1.0, https://github.com/harttle/liquidjs
|
* liquidjs@7.2.0, https://github.com/harttle/liquidjs
|
||||||
* (c) 2016-2019 harttle
|
* (c) 2016-2019 harttle
|
||||||
* Released under the MIT License.
|
* Released under the MIT License.
|
||||||
*/
|
*/
|
||||||
@@ -401,6 +401,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* eslint-disable camelcase */
|
||||||
var defaultOptions = {
|
var defaultOptions = {
|
||||||
root: ['.'],
|
root: ['.'],
|
||||||
cache: false,
|
cache: false,
|
||||||
@@ -408,9 +409,13 @@
|
|||||||
dynamicPartials: true,
|
dynamicPartials: true,
|
||||||
trim_tag_right: false,
|
trim_tag_right: false,
|
||||||
trim_tag_left: false,
|
trim_tag_left: false,
|
||||||
trim_value_right: false,
|
trim_output_right: false,
|
||||||
trim_value_left: false,
|
trim_output_left: false,
|
||||||
greedy: true,
|
greedy: true,
|
||||||
|
tag_delimiter_left: '{%',
|
||||||
|
tag_delimiter_right: '%}',
|
||||||
|
output_delimiter_left: '{{',
|
||||||
|
output_delimiter_right: '}}',
|
||||||
strict_filters: false,
|
strict_filters: false,
|
||||||
strict_variables: false
|
strict_variables: false
|
||||||
};
|
};
|
||||||
@@ -421,6 +426,9 @@
|
|||||||
}
|
}
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
function applyDefault(options) {
|
||||||
|
return __assign({}, defaultOptions, options);
|
||||||
|
}
|
||||||
function normalizeStringArray(value) {
|
function normalizeStringArray(value) {
|
||||||
if (isArray(value))
|
if (isArray(value))
|
||||||
return value;
|
return value;
|
||||||
@@ -441,10 +449,9 @@
|
|||||||
var Scope = /** @class */ (function () {
|
var Scope = /** @class */ (function () {
|
||||||
function Scope(ctx, opts) {
|
function Scope(ctx, opts) {
|
||||||
if (ctx === void 0) { ctx = {}; }
|
if (ctx === void 0) { ctx = {}; }
|
||||||
if (opts === void 0) { opts = defaultOptions; }
|
|
||||||
this.blocks = {};
|
this.blocks = {};
|
||||||
this.blockMode = BlockMode$1.OUTPUT;
|
this.blockMode = BlockMode$1.OUTPUT;
|
||||||
this.opts = __assign({}, defaultOptions, opts);
|
this.opts = applyDefault(opts);
|
||||||
this.contexts = [ctx || {}];
|
this.contexts = [ctx || {}];
|
||||||
}
|
}
|
||||||
Scope.prototype.getAll = function () {
|
Scope.prototype.getAll = function () {
|
||||||
@@ -718,7 +725,7 @@
|
|||||||
if (token.type === 'tag')
|
if (token.type === 'tag')
|
||||||
return token.trimLeft || options.trim_tag_left;
|
return token.trimLeft || options.trim_tag_left;
|
||||||
if (token.type === 'output')
|
if (token.type === 'output')
|
||||||
return token.trimLeft || options.trim_value_left;
|
return token.trimLeft || options.trim_output_left;
|
||||||
}
|
}
|
||||||
function shouldTrimRight(token, inRaw, options) {
|
function shouldTrimRight(token, inRaw, options) {
|
||||||
if (inRaw)
|
if (inRaw)
|
||||||
@@ -726,7 +733,7 @@
|
|||||||
if (token.type === 'tag')
|
if (token.type === 'tag')
|
||||||
return token.trimRight || options.trim_tag_right;
|
return token.trimRight || options.trim_tag_right;
|
||||||
if (token.type === 'output')
|
if (token.type === 'output')
|
||||||
return token.trimRight || options.trim_value_right;
|
return token.trimRight || options.trim_output_right;
|
||||||
}
|
}
|
||||||
function trimLeft(token, greedy) {
|
function trimLeft(token, greedy) {
|
||||||
if (!token || token.type !== 'html')
|
if (!token || token.type !== 'html')
|
||||||
@@ -765,11 +772,13 @@
|
|||||||
|
|
||||||
var DelimitedToken = /** @class */ (function (_super) {
|
var DelimitedToken = /** @class */ (function (_super) {
|
||||||
__extends(DelimitedToken, _super);
|
__extends(DelimitedToken, _super);
|
||||||
function DelimitedToken(raw, pos, input, file, line) {
|
function DelimitedToken(raw, value, pos, input, file, line) {
|
||||||
var _this = _super.call(this, raw, pos, input, file, line) || this;
|
var _this = _super.call(this, raw, pos, input, file, line) || this;
|
||||||
_this.trimLeft = raw[2] === '-';
|
_this.trimLeft = value[0] === '-';
|
||||||
_this.trimRight = raw[raw.length - 3] === '-';
|
_this.trimRight = value[value.length - 1] === '-';
|
||||||
_this.value = raw.slice(_this.trimLeft ? 3 : 2, _this.trimRight ? -3 : -2).trim();
|
_this.value = value
|
||||||
|
.slice(_this.trimLeft ? 1 : 0, _this.trimRight ? -1 : value.length)
|
||||||
|
.trim();
|
||||||
return _this;
|
return _this;
|
||||||
}
|
}
|
||||||
return DelimitedToken;
|
return DelimitedToken;
|
||||||
@@ -777,8 +786,8 @@
|
|||||||
|
|
||||||
var TagToken = /** @class */ (function (_super) {
|
var TagToken = /** @class */ (function (_super) {
|
||||||
__extends(TagToken, _super);
|
__extends(TagToken, _super);
|
||||||
function TagToken(raw, pos, input, file, line) {
|
function TagToken(raw, value$$1, pos, input, file, line) {
|
||||||
var _this = _super.call(this, raw, pos, input, file, line) || this;
|
var _this = _super.call(this, raw, value$$1, pos, input, file, line) || this;
|
||||||
_this.type = 'tag';
|
_this.type = 'tag';
|
||||||
var match = _this.value.match(tagLine);
|
var match = _this.value.match(tagLine);
|
||||||
if (!match) {
|
if (!match) {
|
||||||
@@ -793,8 +802,8 @@
|
|||||||
|
|
||||||
var OutputToken = /** @class */ (function (_super) {
|
var OutputToken = /** @class */ (function (_super) {
|
||||||
__extends(OutputToken, _super);
|
__extends(OutputToken, _super);
|
||||||
function OutputToken(raw, pos, input, file, line) {
|
function OutputToken(raw, value, pos, input, file, line) {
|
||||||
var _this = _super.call(this, raw, pos, input, file, line) || this;
|
var _this = _super.call(this, raw, value, pos, input, file, line) || this;
|
||||||
_this.type = 'output';
|
_this.type = 'output';
|
||||||
return _this;
|
return _this;
|
||||||
}
|
}
|
||||||
@@ -809,11 +818,14 @@
|
|||||||
})(ParseState || (ParseState = {}));
|
})(ParseState || (ParseState = {}));
|
||||||
var Tokenizer = /** @class */ (function () {
|
var Tokenizer = /** @class */ (function () {
|
||||||
function Tokenizer(options) {
|
function Tokenizer(options) {
|
||||||
if (options === void 0) { options = defaultOptions; }
|
this.options = applyDefault(options);
|
||||||
this.options = options;
|
|
||||||
}
|
}
|
||||||
Tokenizer.prototype.tokenize = function (input, file) {
|
Tokenizer.prototype.tokenize = function (input, file) {
|
||||||
var tokens = [];
|
var tokens = [];
|
||||||
|
var tagL = this.options.tag_delimiter_left;
|
||||||
|
var tagR = this.options.tag_delimiter_right;
|
||||||
|
var outputL = this.options.output_delimiter_left;
|
||||||
|
var outputR = this.options.output_delimiter_right;
|
||||||
var p = 0;
|
var p = 0;
|
||||||
var curLine = 1;
|
var curLine = 1;
|
||||||
var state = ParseState.HTML;
|
var state = ParseState.HTML;
|
||||||
@@ -826,33 +838,42 @@
|
|||||||
curLine++;
|
curLine++;
|
||||||
lineBegin = p + 1;
|
lineBegin = p + 1;
|
||||||
}
|
}
|
||||||
var bin = input.substr(p, 2);
|
|
||||||
if (state === ParseState.HTML) {
|
if (state === ParseState.HTML) {
|
||||||
if (bin === '{{' || bin === '{%') {
|
if (input.substr(p, outputL.length) === outputL) {
|
||||||
if (buffer)
|
if (buffer)
|
||||||
tokens.push(new HTMLToken(buffer, col, input, file, line));
|
tokens.push(new HTMLToken(buffer, col, input, file, line));
|
||||||
buffer = bin;
|
buffer = outputL;
|
||||||
line = curLine;
|
line = curLine;
|
||||||
col = p - lineBegin + 1;
|
col = p - lineBegin + 1;
|
||||||
p += 2;
|
p += outputL.length;
|
||||||
state = bin === '{{' ? ParseState.OUTPUT : ParseState.TAG;
|
state = ParseState.OUTPUT;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else if (input.substr(p, tagL.length) === tagL) {
|
||||||
|
if (buffer)
|
||||||
|
tokens.push(new HTMLToken(buffer, col, input, file, line));
|
||||||
|
buffer = tagL;
|
||||||
|
line = curLine;
|
||||||
|
col = p - lineBegin + 1;
|
||||||
|
p += tagL.length;
|
||||||
|
state = ParseState.TAG;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (state === ParseState.OUTPUT && bin === '}}') {
|
else if (state === ParseState.OUTPUT && input.substr(p, outputR.length) === outputR) {
|
||||||
buffer += '}}';
|
buffer += outputR;
|
||||||
tokens.push(new OutputToken(buffer, col, input, file, line));
|
tokens.push(new OutputToken(buffer, buffer.slice(outputL.length, -outputR.length), col, input, file, line));
|
||||||
p += 2;
|
p += outputR.length;
|
||||||
buffer = '';
|
buffer = '';
|
||||||
line = curLine;
|
line = curLine;
|
||||||
col = p - lineBegin + 1;
|
col = p - lineBegin + 1;
|
||||||
state = ParseState.HTML;
|
state = ParseState.HTML;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (bin === '%}') {
|
else if (input.substr(p, tagR.length) === tagR) {
|
||||||
buffer += '%}';
|
buffer += tagR;
|
||||||
tokens.push(new TagToken(buffer, col, input, file, line));
|
tokens.push(new TagToken(buffer, buffer.slice(tagL.length, -tagR.length), col, input, file, line));
|
||||||
p += 2;
|
p += tagR.length;
|
||||||
buffer = '';
|
buffer = '';
|
||||||
line = curLine;
|
line = curLine;
|
||||||
col = p - lineBegin + 1;
|
col = p - lineBegin + 1;
|
||||||
@@ -2176,11 +2197,10 @@
|
|||||||
function Liquid(opts) {
|
function Liquid(opts) {
|
||||||
if (opts === void 0) { opts = {}; }
|
if (opts === void 0) { opts = {}; }
|
||||||
var _this = this;
|
var _this = this;
|
||||||
var options = __assign({}, defaultOptions, normalize(opts));
|
this.options = applyDefault(normalize(opts));
|
||||||
if (options.cache) {
|
if (this.options.cache) {
|
||||||
this.cache = {};
|
this.cache = {};
|
||||||
}
|
}
|
||||||
this.options = options;
|
|
||||||
this.parser = new Parser(this);
|
this.parser = new Parser(this);
|
||||||
this.renderer = new Render();
|
this.renderer = new Render();
|
||||||
this.tokenizer = new Tokenizer(this.options);
|
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 {
|
export default class DelimitedToken extends Token {
|
||||||
trimLeft: boolean;
|
trimLeft: boolean;
|
||||||
trimRight: boolean;
|
trimRight: boolean;
|
||||||
constructor(raw: any, pos: any, input: any, file: any, line: any);
|
constructor(raw: any, value: any, pos: any, input: any, file: any, line: any);
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
import DelimitedToken from './delimited-token';
|
import DelimitedToken from './delimited-token';
|
||||||
export default class OutputToken extends DelimitedToken {
|
export default class OutputToken extends DelimitedToken {
|
||||||
constructor(raw: any, pos: any, input: any, file: any, line: any);
|
constructor(raw: any, value: any, pos: any, input: any, file: any, line: any);
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+1
-1
@@ -2,5 +2,5 @@ import DelimitedToken from './delimited-token';
|
|||||||
export default class TagToken extends DelimitedToken {
|
export default class TagToken extends DelimitedToken {
|
||||||
name: string;
|
name: string;
|
||||||
args: string;
|
args: string;
|
||||||
constructor(raw: any, pos: any, input: any, file: any, line: any);
|
constructor(raw: any, value: any, pos: any, input: any, file: any, line: any);
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+3
-3
@@ -1,6 +1,6 @@
|
|||||||
import { LiquidOptions } from 'src/liquid-options';
|
import { NormalizedFullOptions } from '../liquid-options';
|
||||||
export default class Tokenizer {
|
export default class Tokenizer {
|
||||||
options: LiquidOptions;
|
options: NormalizedFullOptions;
|
||||||
constructor(options?: LiquidOptions);
|
constructor(options?: NormalizedFullOptions);
|
||||||
tokenize(input: string, file?: string): any[];
|
tokenize(input: string, file?: string): any[];
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+2
-2
@@ -1,3 +1,3 @@
|
|||||||
import Token from 'src/parser/token';
|
import Token from 'src/parser/token';
|
||||||
import { LiquidOptions } from 'src/liquid-options';
|
import { NormalizedFullOptions } from 'src/liquid-options';
|
||||||
export default function whiteSpaceCtrl(tokens: Token[], options: LiquidOptions): void;
|
export default function whiteSpaceCtrl(tokens: Token[], options: NormalizedFullOptions): void;
|
||||||
|
|||||||
Vendored
+3
-3
@@ -1,11 +1,11 @@
|
|||||||
import { NormalizedOptions } from '../liquid-options';
|
import { NormalizedFullOptions } from '../liquid-options';
|
||||||
import BlockMode from './block-mode';
|
import BlockMode from './block-mode';
|
||||||
export default class Scope {
|
export default class Scope {
|
||||||
opts: NormalizedOptions;
|
opts: NormalizedFullOptions;
|
||||||
contexts: Array<object>;
|
contexts: Array<object>;
|
||||||
blocks: object;
|
blocks: object;
|
||||||
blockMode: BlockMode;
|
blockMode: BlockMode;
|
||||||
constructor(ctx?: object, opts?: NormalizedOptions);
|
constructor(ctx?: object, opts?: NormalizedFullOptions);
|
||||||
getAll(): object;
|
getAll(): object;
|
||||||
get(path: string): any;
|
get(path: string): any;
|
||||||
set(path: string, v: any): void;
|
set(path: string, v: any): void;
|
||||||
|
|||||||
Generated
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "liquidjs",
|
"name": "liquidjs",
|
||||||
"version": "7.1.0",
|
"version": "7.2.0",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "liquidjs",
|
"name": "liquidjs",
|
||||||
"version": "7.1.0",
|
"version": "7.2.0",
|
||||||
"description": "Liquid template engine by pure JavaScript: compatible to shopify, easy to extend.",
|
"description": "Liquid template engine by pure JavaScript: compatible to shopify, easy to extend.",
|
||||||
"main": "dist/liquid.common.js",
|
"main": "dist/liquid.common.js",
|
||||||
"types": "dist/liquid.d.ts",
|
"types": "dist/liquid.d.ts",
|
||||||
|
|||||||
Reference in New Issue
Block a user