com.github.jknack.handlebars.TagType Java Examples

The following examples show how to use com.github.jknack.handlebars.TagType. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AllHelperTest.java    From roboconf-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void testUnsupportedContext_unknownType() throws Exception {

	Context ctx = Context.newContext( new Object());
	Handlebars handlebars = Mockito.mock( Handlebars.class );
	Template tpl = Mockito.mock(  Template.class  );
	Options opts = new Options(
			handlebars, "helper", TagType.SECTION, ctx, tpl, tpl,
			new Object[ 0 ],
			new HashMap<String,Object>( 0 ));

	AllHelper helper = new AllHelper();
	Assert.assertEquals( "", helper.apply( null, opts ));
}
 
Example #2
Source File: AllHelperTest.java    From roboconf-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void testUnsupportedContext_nullContext() throws Exception {

	Context ctx = Context.newContext( null );
	Handlebars handlebars = Mockito.mock( Handlebars.class );
	Template tpl = Mockito.mock(  Template.class  );
	Options opts = new Options(
			handlebars, "helper", TagType.SECTION, ctx, tpl, tpl,
			new Object[ 0 ],
			new HashMap<String,Object>( 0 ));

	AllHelper helper = new AllHelper();
	Assert.assertEquals( "", helper.apply( null, opts ));
}
 
Example #3
Source File: TemplateExpressionEvaluator.java    From molgenis with GNU Lesser General Public License v3.0 5 votes vote down vote up
private List<List<String>> getTemplateVariables(Template template) {
  List<String> tagNames = template.collect(TagType.VAR);
  List<List<String>> composedTagNames =
      tagNames.stream().map(tagName -> asList(tagName.split("\\."))).collect(toList());
  composedTagNames.forEach(this::validateTemplateVariable);
  return composedTagNames;
}
 
Example #4
Source File: TemplateProcessor.java    From cloudbreak with Apache License 2.0 4 votes vote down vote up
private List<String> queryTemplateParameters(String sourceTemplate)
        throws IOException {
    Template template = handlebars.compileInline(sourceTemplate, HandlebarTemplate.DEFAULT_PREFIX.key(), HandlebarTemplate.DEFAULT_POSTFIX.key());
    return template.collect(TagType.VAR);
}