use of com.squarespace.template.CodeBuilder in project template-compiler by Squarespace.
the class CoreFormattersTest method testApplyPartial.
@Test
public void testApplyPartial() throws CodeException {
String partials = "{\"block.item\": \"this {@} value\"}";
String input = "{\"foo\": 123}";
CodeMaker mk = maker();
CodeBuilder cb = builder().text("hi ");
Arguments args = mk.args(" block.item");
APPLY.validateArgs(args);
cb.var("foo", mk.fmt(APPLY, args));
Instruction root = cb.text("!").eof().build();
Context ctx = new Context(JsonUtils.decode(input));
ctx.setCompiler(compiler());
ctx.setPartials(JsonUtils.decode(partials));
ctx.execute(root);
assertContext(ctx, "hi this 123 value!");
}
Aggregations