Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function Compilable(source: any) {
// console.log('In Compilable: ' + source);
const precompiled = precompile(source);
// console.log('Precompiled');
const component = Component(precompiled);
// console.log(`Compiled Component: ${component}`);
return component;
}
compile(template: string, meta: TemplateMeta = {}): Template {
let wrapper = JSON.parse(precompile(template, { meta }));
let factory = templateFactory(wrapper);
return factory.create(this.compileOptions);
}
preprocess(
template: string,
meta?: AnnotatedModuleLocator
): Template> {
let wrapper = JSON.parse(precompile(template));
let factory = templateFactory(wrapper);
return factory.create(templateMeta(meta || DEFAULT_TEST_META));
}
export function createTemplate(
templateSource: string,
options?: PrecompileOptions
): TemplateFactory {
let wrapper: SerializedTemplateWithLazyBlock = JSON.parse(
rawPrecompile(templateSource, options)
);
return templateFactory(wrapper);
}
export function createTemplate(templateSource: string, meta: TemplateMeta = {}): ParsedLayout {
let wrapper: SerializedTemplateWithLazyBlock = JSON.parse(precompile(templateSource, { meta }));
let block: SerializedTemplateBlock = JSON.parse(wrapper.block);
return { block, referer: meta };
}
'generates id in node'() {
let template = precompile('hello');
let obj = JSON.parse(template);
this.assert.equal(obj.id, '14+n+4pQ', 'short sha of template source');
template = precompile('hello', { meta: { moduleName: 'template/hello' } });
obj = JSON.parse(template);
this.assert.equal(obj.id, 'Ohs2KKrA', 'short sha of template source and meta');
}
}
registerNativeComponent(name, value) {
this.registerNativeElement(name, value);
const handle = Application.resolver.registerTemplateOnlyComponent(name);
Application.resolverDelegate.registerComponent(name, handle, precompile(`<${name.toLowerCase()} ...attributes> {{yield}} `), TEMPLATE_ONLY_COMPONENT);
}
registerHelper(name, func) {
processString(content, relativePath) {
let specifier = getTemplateSpecifier(this.options.rootName, relativePath);
return 'export default ' + precompile(content, { meta: { specifier, '': true } }) + ';';
}
}
return walkTree(templatesDir, (relativePath, fileData) => {
let moduleName = relativePath.substr(templatesDir.length + 1);
let isComponent = false;
moduleName = moduleName.replace('.hbs', '');
let componentName;
if (moduleName.indexOf(COMPONENT_PATH) === 0) {
isComponent = true;
componentName = moduleName.substr(COMPONENT_PATH.length);
}
precompile(fileData, {
rawSource: fileData,
isComponent,
moduleName,
componentName,
availableGraph:stylesGraph,
usedGraph:usedStylesGraph,
plugins: {
ast: [htmlGraphBuilder]
}
});
}).then(() => {
return usedStylesGraph;