Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
renderMain(
template: Template,
self: PathReference,
builder: ElementBuilder
): TemplateIterator {
let layout = template.asLayout();
let handle = layout.compile(this.context);
// TODO, figure out runtime program stuff
return renderJitMain(
{ program: this.program, env: this, resolver: this.resolver },
this.context,
self,
builder,
handle
);
}
appendTo(selector: string) {
let element = assertElement(document.querySelector(selector) as SimpleElement);
let self = new UpdatableRootReference(this);
let cursor = { element, nextSibling: null };
let handle = unwrapTemplate(this.template)
.asLayout()
.compile(this.syntax);
let templateIterator = renderJitMain(
this.runtime,
this.syntax,
self,
clientBuilder(this.runtime.env, cursor),
unwrapHandle(handle)
);
let result;
do {
result = templateIterator.next();
} while (!result.done);
this.element = firstElementChild(element)!;
}
}
export function renderTemplate(
src: string,
{ runtime, syntax }: JitTestDelegateContext,
self: VersionedPathReference,
builder: ElementBuilder
): RenderResult {
let template = preprocess(src);
let handle = unwrapTemplate(template)
.asLayout()
.compile(syntax);
let iterator = renderJitMain(runtime, syntax, self, builder, unwrapHandle(handle));
return renderSync(runtime.env, iterator);
}
export function renderTemplate(
src: string,
{ runtime, syntax }: JitTestDelegateContext,
self: PathReference,
builder: ElementBuilder
): RenderResult {
let template = preprocess(src);
let iterator = renderJitMain(runtime, syntax, self, builder, template.asLayout().compile(syntax));
return renderSync(runtime.env, iterator);
}
async getTemplateIterator(
app: Application,
env: Environment,
builder: ElementBuilder,
dynamicScope: DynamicScope,
self: PathReference
): Promise {
let resolver = this.getResolver(app);
let context = this.getContext(resolver);
let runtime = CustomJitRuntime(resolver, context, app.env);
let mainLayout = unwrapTemplate(templateFactory(mainTemplate).create());
let handle = unwrapHandle(mainLayout.asLayout().compile(context));
return Promise.resolve(
renderJitMain(
runtime,
context,
self,
builder,
handle,
dynamicScope
)
);
}