本文整理汇总了TypeScript中@glimmer/compiler.precompile函数的典型用法代码示例。如果您正苦于以下问题:TypeScript precompile函数的具体用法?TypeScript precompile怎么用?TypeScript precompile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了precompile函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: function
QUnit.test('generates id in node', function (assert) {
let template = precompile('hello');
let obj = JSON.parse(template);
assert.equal(obj.id, '3TlrituF', 'short sha of template source');
template = precompile('hello', { meta: {moduleName: 'template/hello'} });
obj = JSON.parse(template);
assert.equal(obj.id, 'CiDxizBQ', 'short sha of template source and meta');
});
开发者ID:asakusuma,项目名称:glimmer,代码行数:8,代码来源:node-test.ts
示例2: ast
function ast(template: string): AST.Program {
let program: Option<AST.Program> = null;
function extractProgram(): ASTPlugin {
return {
name: 'extract-program',
visitor: {
Program: {
exit(node: AST.Program): void {
program = clone(node);
},
},
},
};
}
let options = compileOptions({
moduleName: '-top-level',
});
options.plugins!.ast!.push(extractProgram);
precompile(template, options);
return program!;
}
开发者ID:cibernox,项目名称:ember.js,代码行数:27,代码来源:transform-test-case.ts
示例3:
QUnit.test('returned meta is correct', assert => {
let wire = JSON.parse(precompile('Hi, {{name}}!', {
meta: {
moduleName: 'my/module-name',
metaIsOpaque: 'yes'
} as any as TemplateMeta
}));
assert.equal(wire.meta.moduleName, 'my/module-name', 'Template has correct meta');
assert.equal(wire.meta.metaIsOpaque, 'yes', 'Template has correct meta');
});
开发者ID:asakusuma,项目名称:glimmer,代码行数:11,代码来源:compile-options-test.ts
示例4: createTemplate
export function createTemplate(templateSource: string, meta: TemplateMeta = {}): ParsedLayout {
let wrapper: SerializedTemplateWithLazyBlock<TemplateMeta> = JSON.parse(precompile(templateSource, { meta }));
let block: SerializedTemplateBlock = JSON.parse(wrapper.block);
return { block, referrer: meta };
}
开发者ID:jayphelps,项目名称:glimmer,代码行数:6,代码来源:shared.ts
示例5: beforeEach
}
interface OwnerMeta {
owner: {};
}
let serializedTemplate: SerializedTemplateWithLazyBlock<TestMeta>;
let serializedTemplateNoId: SerializedTemplateWithLazyBlock<TestMeta>;
QUnit.module("templateFactory", {
beforeEach() {
env = new TestEnvironment();
let templateJs = precompile("<div>{{name}}</div>", {
meta: {
version: 12,
lang: 'es',
moduleName: "template/module/name"
}
});
serializedTemplate = JSON.parse(templateJs);
serializedTemplate.id = 'server-id-1';
serializedTemplateNoId = JSON.parse(templateJs);
serializedTemplateNoId.id = null;
}
});
QUnit.test("id of serialized template is exposed on the factory", assert => {
let factory = templateFactory(serializedTemplate);
assert.ok(factory.id, 'is present');
assert.equal(factory.id, serializedTemplate.id, 'id matches serialized template id');
开发者ID:mmun,项目名称:glimmer,代码行数:31,代码来源:template-test.ts
示例6: precompile
/**
Uses HTMLBars `compile` function to process a string into a compiled template string.
The returned string must be passed through `Ember.HTMLBars.template`.
This is not present in production builds.
@private
@method precompile
@param {String} templateString This is the string to be compiled by HTMLBars.
*/
export default function precompile(templateString: string, options: CompileOptions): string {
return glimmerPrecompile(templateString, compileOptions(options));
}
开发者ID:GreatWizard,项目名称:ember.js,代码行数:13,代码来源:precompile.ts
注:本文中的@glimmer/compiler.precompile函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论