teapot-template
v0.0.1
Published
A Frontend java framework for developing modern web applications
Downloads
3
Maintainers
Readme
teapot-template
A template engine with annotation syntax
Templates
This example shows how you can create and render a template
let html = "<div class=@("class_" + test)>" +
"@for(int i = 0;i < 10;i++)" +
"<div>@(test) @(i)</div>" +
"</div>";
let engine: TeapotTemplateEngine = new TeapotTemplateEngine;
let templateParseResult: Unhandled<TemplateParseException, TeapotTemplate> = engine.parse(html);
if (templateParseResult.isThrown()) {
throw templateParseResult.getException();
}
let template: TeapotTemplate = templateParseResult.get();
let pack: TeapotTemplatePack = template.pack();
console.log(JSON.stringify(pack));
let unpackedTemplate: Unhandled<UnpackException, TeapotTemplate> = engine.fromPack(pack);
if (unpackedTemplate.isThrown()) {
throw unpackedTemplate.getException();
}
let pack1: TeapotTemplatePack = unpackedTemplate.get().pack();
console.log("");
console.log(JSON.stringify(pack1));