mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-19 14:30:38 -07:00
1.6.0
This commit is contained in:
Vendored
+20
-8
@@ -242,7 +242,7 @@ var _engine = {
|
|||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
parse: function parse(html, filepath) {
|
parse: function parse(html, filepath) {
|
||||||
var tokens = tokenizer.parse(html, filepath);
|
var tokens = tokenizer.parse(html, filepath, this.options);
|
||||||
return this.parser.parse(tokens);
|
return this.parser.parse(tokens);
|
||||||
},
|
},
|
||||||
render: function render(tpl, ctx, opts) {
|
render: function render(tpl, ctx, opts) {
|
||||||
@@ -339,14 +339,16 @@ var _engine = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function factory(options) {
|
function factory(options) {
|
||||||
options = _.assign({}, options);
|
options = _.assign({
|
||||||
|
root: ['.'],
|
||||||
|
cache: false,
|
||||||
|
extname: '.liquid',
|
||||||
|
trim_right: false,
|
||||||
|
trim_left: false
|
||||||
|
}, options);
|
||||||
options.root = normalizeStringArray(options.root);
|
options.root = normalizeStringArray(options.root);
|
||||||
if (!options.root.length) options.root = ['.'];
|
|
||||||
|
|
||||||
options.extname = options.extname || '.liquid';
|
|
||||||
|
|
||||||
var engine = Object.create(_engine);
|
var engine = Object.create(_engine);
|
||||||
|
|
||||||
engine.init(Tag(), Filter(options), options);
|
engine.init(Tag(), Filter(options), options);
|
||||||
return engine;
|
return engine;
|
||||||
}
|
}
|
||||||
@@ -1195,11 +1197,13 @@ var TokenizationError = require('./util/error.js').TokenizationError;
|
|||||||
var _ = require('./util/underscore.js');
|
var _ = require('./util/underscore.js');
|
||||||
var assert = require('../src/util/assert.js');
|
var assert = require('../src/util/assert.js');
|
||||||
|
|
||||||
function parse(html, filepath) {
|
function parse(html, filepath, options) {
|
||||||
assert(_.isString(html), 'illegal input type');
|
assert(_.isString(html), 'illegal input type');
|
||||||
|
|
||||||
|
html = whiteSpaceCtrl(html, options);
|
||||||
|
|
||||||
var tokens = [];
|
var tokens = [];
|
||||||
var syntax = /({%(.*?)%})|({{(.*?)}})/g;
|
var syntax = /({%-?(.*?)-?%})|({{-?(.*?)-?}})/g;
|
||||||
var result, htmlFragment, token;
|
var result, htmlFragment, token;
|
||||||
var lastMatchEnd = 0,
|
var lastMatchEnd = 0,
|
||||||
lastMatchBegin = -1,
|
lastMatchBegin = -1,
|
||||||
@@ -1266,7 +1270,15 @@ function parse(html, filepath) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function whiteSpaceCtrl(html, options) {
|
||||||
|
options = options || {};
|
||||||
|
var rLeft = options.trim_left ? /\s+({[{%])/g : /\s+({[{%]-)/g;
|
||||||
|
var rRight = options.trim_right ? /([}%]})\s+/g : /(-[}%]})\s+/g;
|
||||||
|
return html.replace(rLeft, '$1').replace(rRight, '$1');
|
||||||
|
}
|
||||||
|
|
||||||
exports.parse = parse;
|
exports.parse = parse;
|
||||||
|
exports.whiteSpaceCtrl = whiteSpaceCtrl;
|
||||||
|
|
||||||
},{"../src/util/assert.js":16,"./lexical.js":8,"./util/error.js":17,"./util/underscore.js":21}],16:[function(require,module,exports){
|
},{"../src/util/assert.js":16,"./lexical.js":8,"./util/error.js":17,"./util/underscore.js":21}],16:[function(require,module,exports){
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|||||||
Vendored
+3
-2
File diff suppressed because one or more lines are too long
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "shopify-liquid",
|
"name": "shopify-liquid",
|
||||||
"version": "1.5.4",
|
"version": "1.6.0",
|
||||||
"description": "A feature-rich Liquid template engine for Node.js and browsers, with compliance with the Ruby version.",
|
"description": "A feature-rich Liquid template engine for Node.js and browsers, with compliance with the Ruby version.",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Reference in New Issue
Block a user