本文整理汇总了TypeScript中@glimmer/syntax.builders.mustache方法的典型用法代码示例。如果您正苦于以下问题:TypeScript builders.mustache方法的具体用法?TypeScript builders.mustache怎么用?TypeScript builders.mustache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@glimmer/syntax.builders
的用法示例。
在下文中一共展示了builders.mustache方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
MustacheStatement: function(node) {
if (node.path.original === 'x') {
return b.mustache('y');
} else if (node.path.original === 'y') {
return b.mustache('z');
}
}
示例2: traverse
assert.throws(() => {
traverse(ast, {
MustacheStatement: {
[eventName](node) {
if (node.path.parts[0] === 'z') {
return [
b.mustache('a'),
b.mustache('b'),
b.mustache('c')
];
}
}
}
});
}, cannotReplaceNode(attr.value, attr, 'value'));
示例3: test
test('BooleanLiteral', assert => {
const ast = b.program([
b.mustache('foo', undefined,
b.hash([b.pair('bar', b.boolean(true))])
)
]);
assert.equal(print(ast), '{{foo bar=true}}');
});
示例4: parse
QUnit.test('Inside of a block', () => {
let ast = parse(`{{y}}{{#w}}{{x}}{{y}}{{z}}{{/w}}`);
traverse(ast, {
MustacheStatement(node) {
if (node.path.parts[0] === 'y') {
return [
b.mustache('a'),
b.mustache('b'),
b.mustache('c')
];
}
}
});
astEqual(ast, `{{a}}{{b}}{{c}}{{#w}}{{x}}{{a}}{{b}}{{c}}{{z}}{{/w}}`);
});
示例5: array
QUnit.test(`[${eventName}] Replacing self in an array (returning an array with multiple nodes)`, () => {
let ast = parse(`{{x}}{{y}}{{z}}`);
traverse(ast, {
MustacheStatement: {
[eventName](node) {
if (node.path.parts[0] === 'y') {
return [
b.mustache('a'),
b.mustache('b'),
b.mustache('c')
];
}
}
}
});
astEqual(ast, `{{x}}{{a}}{{b}}{{c}}{{z}}`);
});
示例6: key
QUnit.test(`[${eventName}] Replacing self in a key (returning an array with a single node)`, () => {
let ast = parse(`<x y={{z}} />`);
traverse(ast, {
MustacheStatement: {
[eventName](node) {
if (node.path.parts[0] === 'z') {
return [b.mustache('a')];
}
}
}
});
astEqual(ast, `<x y={{a}} />`);
});
示例7: key
QUnit.test(`[${eventName}] Replacing self in a key (returning a node)`, () => {
let ast = parse(`<x y={{z}} />`);
traverse(ast, {
MustacheStatement: {
[eventName](node: AST.MustacheStatement) {
if (node.path.type === 'PathExpression' && node.path.parts[0] === 'z') {
return b.mustache('a');
}
return;
}
}
});
astEqual(ast, `<x y={{a}} />`);
});
示例8: array
QUnit.test(`[${eventName}] Replacing self in an array (returning an array with a single node)`, () => {
let ast = parse(`{{x}}{{y}}{{z}}`);
traverse(ast, {
MustacheStatement: {
[eventName](node: AST.MustacheStatement) {
if (node.path.type === 'PathExpression' && node.path.parts[0] === 'y') {
return [b.mustache('a')];
}
return;
}
}
});
astEqual(ast, `{{x}}{{a}}{{z}}`);
});