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