本文整理匯總了TypeScript中glimmer-runtime.templateFactory函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript templateFactory函數的具體用法?TypeScript templateFactory怎麽用?TypeScript templateFactory使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了templateFactory函數的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: templateFactory
QUnit.test("generates id if no id is on the serialized template", assert => {
let factory1 = templateFactory(serializedTemplateNoId);
let factory2 = templateFactory(serializedTemplateNoId);
assert.ok(factory1.id, 'is present');
assert.ok(factory2.id, 'is present');
assert.notEqual(factory1.id, factory2.id, 'factories without underlying id create new id per factory');
});
示例2:
QUnit.test("can inject per environment things into meta", assert => {
let owner = {};
let factory = templateFactory<TestMeta, OwnerMeta>(serializedTemplate);
let template = factory.create(env, { owner });
assert.strictEqual(template.meta.owner, owner, 'is owner');
assert.deepEqual(template.meta, {
version: 12,
lang: 'es',
moduleName: "template/module/name",
owner
}, 'template has expected meta');
});