|
|
|
@ -9,7 +9,6 @@ export const jsepCurlyHook = {
|
|
|
|
|
const OCURLY_CODE = 123; // {
|
|
|
|
|
const CCURLY_CODE = 125; // }
|
|
|
|
|
let start = -1; |
|
|
|
|
let end = -1; |
|
|
|
|
const { context } = env; |
|
|
|
|
if ( |
|
|
|
|
!jsep.isIdentifierStart(context.code) && |
|
|
|
@ -21,22 +20,17 @@ export const jsepCurlyHook = {
|
|
|
|
|
context.index += 1; |
|
|
|
|
context.gobbleExpressions(CCURLY_CODE); |
|
|
|
|
if (context.code === CCURLY_CODE) { |
|
|
|
|
if (start != -1 && end == -1) { |
|
|
|
|
end = context.index; |
|
|
|
|
} |
|
|
|
|
context.index += 1; |
|
|
|
|
if (start != -1 && end != -1) { |
|
|
|
|
env.node = { |
|
|
|
|
type: jsep.IDENTIFIER, |
|
|
|
|
name: /{{(.*?)}}/.test(context.expr) |
|
|
|
|
? // start would be the position of the first curly bracket
|
|
|
|
|
// add 2 to point to the first character for expressions like {{col1}}
|
|
|
|
|
context.expr.slice(start + 2, end) |
|
|
|
|
context.expr.slice(start + 2, context.index - 1) |
|
|
|
|
: // start would be the position of the first curly bracket
|
|
|
|
|
// add 1 to point to the first character for expressions like {col1}
|
|
|
|
|
context.expr.slice(start + 1, end), |
|
|
|
|
context.expr.slice(start + 1, context.index - 1), |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
return env.node; |
|
|
|
|
} else { |
|
|
|
|
context.throwError('Unclosed }'); |
|
|
|
|