本文整理汇总了TypeScript中@glimmer/syntax.builders类的典型用法代码示例。如果您正苦于以下问题:TypeScript builders类的具体用法?TypeScript builders怎么用?TypeScript builders使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了builders类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: function
MustacheStatement: function(node) {
if (node.path.original === 'baz') {
return b.mustache('x-baz');
} else if (node.path.original === 'bat') {
return b.mustache('x-bat');
}
}
开发者ID:asakusuma,项目名称:glimmer,代码行数:7,代码来源:manipulating-node-test.ts
示例2:
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}}');
});
开发者ID:jayphelps,项目名称:glimmer,代码行数:8,代码来源:print-test.ts
示例3: 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'));
开发者ID:asakusuma,项目名称:glimmer,代码行数:15,代码来源:manipulating-node-test.ts
示例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}}`);
});
开发者ID:asakusuma,项目名称:glimmer,代码行数:17,代码来源:manipulating-node-test.ts
示例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}}`);
});
开发者ID:asakusuma,项目名称:glimmer,代码行数:19,代码来源:manipulating-node-test.ts
示例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}} />`);
});
开发者ID:asakusuma,项目名称:glimmer,代码行数:15,代码来源:manipulating-node-test.ts
示例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}} />`);
});
开发者ID:jayphelps,项目名称:glimmer,代码行数:16,代码来源:manipulating-node-test.ts
注:本文中的@glimmer/syntax.builders类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论