try to parse expressions as javascript before interpreting them as an identifier (#424)

pull/426/head
Conduitry 8 years ago
parent 38ee4f15cf
commit eab3f62f25

@ -3,16 +3,6 @@ import { parseExpressionAt } from 'acorn';
export default function readExpression ( parser ) {
const start = parser.index;
const name = parser.readUntil( /\s*}}/ );
if ( name && /^[a-z]+$/.test( name ) ) {
return {
type: 'Identifier',
start,
end: start + name.length,
name
};
}
parser.index = start;
try {
@ -21,6 +11,15 @@ export default function readExpression ( parser ) {
return node;
} catch ( err ) {
const name = parser.readUntil( /\s*}}/ );
if ( name && /^[a-z]+$/.test( name ) ) {
return {
type: 'Identifier',
start,
end: start + name.length,
name
};
}
parser.acornError( err );
}
}

Loading…
Cancel
Save