本文整理汇总了TypeScript中@glimmer/syntax.preprocess函数的典型用法代码示例。如果您正苦于以下问题:TypeScript preprocess函数的具体用法?TypeScript preprocess怎么用?TypeScript preprocess使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了preprocess函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: actionsEqual
function actionsEqual(input, expectedActions) {
let ast = preprocess(input);
let templateVisitor = new TemplateVisitor();
templateVisitor.visit(ast);
let actualActions = templateVisitor.actions;
// Remove the AST node reference from the actions to keep tests leaner
for (let i = 0; i < actualActions.length; i++) {
actualActions[i][1].shift();
}
assert.deepEqual(actualActions, expectedActions);
}
开发者ID:asakusuma,项目名称:glimmer,代码行数:14,代码来源:template-visitor-node-test.ts
示例2: test
test('plugins are provided the syntax package', assert => {
assert.expect(1);
preprocess('<div></div>', {
plugins: {
ast: [
({ syntax }) => {
assert.equal(syntax.Walker, Walker);
return { name: 'plugin-a', visitor: {} };
}
]
}
});
});
开发者ID:jayphelps,项目名称:glimmer,代码行数:15,代码来源:plugin-node-test.ts
示例3: astEqual
export function astEqual(actual: any | null | undefined, expected: any | null | undefined, message?: string) {
if (typeof actual === 'string') {
actual = parse(actual);
}
if (typeof expected === 'string') {
expected = parse(expected);
}
actual = normalizeNode(actual);
expected = normalizeNode(expected);
QUnit.assert.deepEqual(actual, expected, message);
}
开发者ID:jayphelps,项目名称:glimmer,代码行数:13,代码来源:support.ts
示例4: parse
QUnit.test('Should recurrsively walk the keys in the transformed node', () => {
let ast = parse(`{{#foo}}{{#bar}}{{baz}}{{/bar}}{{else}}{{#bar}}{{bat}}{{/bar}}{{/foo}}`);
traverse(ast, {
BlockStatement: function(node) {
if (node.path.original === 'foo') {
return b.block(b.path('x-foo'), node.params, node.hash, node.program, node.inverse, node.loc);
} else if (node.path.original === 'bar') {
return b.block(b.path('x-bar'), node.params, node.hash, node.program, node.inverse, node.loc);
}
return;
},
MustacheStatement: function(node) {
if (node.path.original === 'baz') {
return b.mustache('x-baz');
} else if (node.path.original === 'bat') {
return b.mustache('x-bat');
}
return;
}
});
astEqual(ast, `{{#x-foo}}{{#x-bar}}{{x-baz}}{{/x-bar}}{{else}}{{#x-bar}}{{x-bat}}{{/x-bar}}{{/x-foo}}`);
});
开发者ID:jayphelps,项目名称:glimmer,代码行数:25,代码来源:manipulating-node-test.ts
示例5: function
test('Element modifiers', function() {
let ast = parse(`<div {{modifier}}{{modifier param1 param2 key1=value key2=value}}></div>`);
traversalEqual(ast, [
['enter', ast],
['enter', ast.body[0]],
['enter', ast.body[0].modifiers[0]],
['enter', ast.body[0].modifiers[0].path],
['exit', ast.body[0].modifiers[0].path],
['enter', ast.body[0].modifiers[0].hash],
['exit', ast.body[0].modifiers[0].hash],
['exit', ast.body[0].modifiers[0]],
['enter', ast.body[0].modifiers[1]],
['enter', ast.body[0].modifiers[1].path],
['exit', ast.body[0].modifiers[1].path],
['enter', ast.body[0].modifiers[1].params[0]],
['exit', ast.body[0].modifiers[1].params[0]],
['enter', ast.body[0].modifiers[1].params[1]],
['exit', ast.body[0].modifiers[1].params[1]],
['enter', ast.body[0].modifiers[1].hash],
['enter', ast.body[0].modifiers[1].hash.pairs[0]],
['enter', ast.body[0].modifiers[1].hash.pairs[0].value],
['exit', ast.body[0].modifiers[1].hash.pairs[0].value],
['exit' , ast.body[0].modifiers[1].hash.pairs[0]],
['enter', ast.body[0].modifiers[1].hash.pairs[1]],
['enter', ast.body[0].modifiers[1].hash.pairs[1].value],
['exit', ast.body[0].modifiers[1].hash.pairs[1].value],
['exit' , ast.body[0].modifiers[1].hash.pairs[1]],
['exit', ast.body[0].modifiers[1].hash],
['exit', ast.body[0].modifiers[1]],
['exit', ast.body[0]],
['exit', ast]
]);
});
开发者ID:asakusuma,项目名称:glimmer,代码行数:34,代码来源:visiting-node-test.ts
示例6: Plugin
test('AST plugins can be chained', assert => {
assert.expect(2);
let expected = "OOOPS, MESSED THAT UP!";
function Plugin() { }
Plugin.prototype.transform = function() {
return expected;
};
function SecondaryPlugin() { }
SecondaryPlugin.prototype.transform = function(ast) {
assert.equal(ast, expected, 'return value from AST transform is used');
return 'BOOM!';
};
let ast = parse('<div></div>', {
plugins: {
ast: [
Plugin,
SecondaryPlugin
]
}
});
assert.equal(ast, 'BOOM!', 'return value from last AST transform is used');
});
开发者ID:asakusuma,项目名称:glimmer,代码行数:28,代码来源:plugin-node-test.ts
示例7: compareWalkedNodes
function compareWalkedNodes(html, expected) {
let ast = parse(html);
let walker = new Walker();
let nodes = [];
walker.visit(ast, function(node) {
nodes.push(node.type);
});
QUnit.assert.deepEqual(nodes, expected);
}
开发者ID:asakusuma,项目名称:glimmer,代码行数:11,代码来源:walker-node-test.ts
注:本文中的@glimmer/syntax.preprocess函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论