mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-15 12:20:40 -07:00
tags: use scope.opts insteadof scope.get('liquid')
This commit is contained in:
+7
-9
@@ -11,6 +11,9 @@ var Scope = {
|
||||
return ctx
|
||||
},
|
||||
get: function (str) {
|
||||
if (str === 'liquid') {
|
||||
throw new Error('NO LONGER SUPPORTED: use scope.opts instread of scope.get("liquid")')
|
||||
}
|
||||
try {
|
||||
return this.getPropertyByPath(this.scopes, str)
|
||||
} catch (e) {
|
||||
@@ -168,19 +171,14 @@ function matchRightBracket (str, begin) {
|
||||
}
|
||||
|
||||
exports.factory = function (ctx, opts) {
|
||||
opts = _.assign({
|
||||
var defaultOptions = {
|
||||
strict_variables: false,
|
||||
strict_filters: false,
|
||||
blocks: {},
|
||||
root: []
|
||||
}, opts)
|
||||
|
||||
ctx = _.assign(ctx, {
|
||||
liquid: opts
|
||||
})
|
||||
|
||||
}
|
||||
var scope = Object.create(Scope)
|
||||
scope.opts = opts
|
||||
scope.scopes = [ctx]
|
||||
scope.opts = _.assign(defaultOptions, opts)
|
||||
scope.scopes = [ctx || {}]
|
||||
return scope
|
||||
}
|
||||
|
||||
+8
-6
@@ -7,7 +7,7 @@ function initError () {
|
||||
}
|
||||
}
|
||||
|
||||
function initLiquidError (message, token) {
|
||||
function initLiquidError (err, token) {
|
||||
initError.call(this)
|
||||
|
||||
this.input = token.input
|
||||
@@ -15,12 +15,14 @@ function initLiquidError (message, token) {
|
||||
this.file = token.file
|
||||
|
||||
var context = mkContext(token.input, token.line)
|
||||
this.message = mkMessage(message, token)
|
||||
this.stack = context + '\n' + (this.stack || this.message)
|
||||
this.message = mkMessage(err.message, token)
|
||||
this.stack = context +
|
||||
'\n' + (this.stack || this.message) +
|
||||
(err.stack ? '\nFrom ' + err.stack : '')
|
||||
}
|
||||
|
||||
function TokenizationError (message, token) {
|
||||
initLiquidError.call(this, message, token)
|
||||
initLiquidError.call(this, {message: message}, token)
|
||||
}
|
||||
TokenizationError.prototype = Object.create(Error.prototype)
|
||||
TokenizationError.prototype.constructor = TokenizationError
|
||||
@@ -29,7 +31,7 @@ function ParseError (e, token) {
|
||||
_.assign(this, e)
|
||||
this.originalError = e
|
||||
|
||||
initLiquidError.call(this, e.message, token)
|
||||
initLiquidError.call(this, e, token)
|
||||
}
|
||||
ParseError.prototype = Object.create(Error.prototype)
|
||||
ParseError.prototype.constructor = ParseError
|
||||
@@ -42,7 +44,7 @@ function RenderError (e, tpl) {
|
||||
_.assign(this, e)
|
||||
this.originalError = e
|
||||
|
||||
initLiquidError.call(this, e.message, tpl.token)
|
||||
initLiquidError.call(this, e, tpl.token)
|
||||
}
|
||||
RenderError.prototype = Object.create(Error.prototype)
|
||||
RenderError.prototype.constructor = RenderError
|
||||
|
||||
Reference in New Issue
Block a user