@Test public void testHelper() { final MustacheEngine engine = MustacheEngineBuilder.newBuilder() .registerHelpers(HelpersBuilder.empty().addInvoke().build()) .build(); List<String> list = ImmutableList.of("foo", "bar", "baz"); Map<String, Object> data = ImmutableMap.of("string", "foo", "list", list); assertEquals("oo", engine .compileMustache("invoke_01", "{{invoke 1 m='substring'}}") .render("foo")); assertEquals("bar", engine.compileMustache("invoke_02", "{{invoke 1 m='get'}}") .render(list)); assertEquals("FOOBARBAZ", engine.compileMustache("invoke_03", "{{#invoke 'list' m='get'}}{{#each this}}{{toUpperCase}}{{/each}}{{/invoke}}") .render(data)); assertEquals("3", engine .compileMustache("invoke_04", "{{invoke on=list m='size'}}") .render(data)); assertEquals( "false", engine .compileMustache("invoke_05", "{{invoke on=list method='isEmpty'}}") .render(data)); assertEquals("boo", engine.compileMustache("invoke_06", "{{invoke 'f' 'b' on='foo' m='replace'}}") .render(null)); assertEquals("2", engine.compileMustache("invoke_07", "{{#invoke ':' on='foo:bar' m='split'}}{{this.length}}{{/invoke}}") .render(null)); }
public static InvokeHelper of(String defaultMethodName) { return new InvokeHelper(null, defaultMethodName); }
InvokeHelper extends BasicHelper { public static InvokeHelper of(String defaultMethodName) { return new InvokeHelper(null, defaultMethodName); } }
InvokeHelper extends BasicHelper { public static InvokeHelper of(String defaultMethodName) { return new InvokeHelper(null, defaultMethodName); } InvokeHelper();  InvokeHelper(ClassLoader classLoader);  InvokeHelper(ClassLoader classLoader, String defaultMethodName); }
InvokeHelper extends BasicHelper { public static InvokeHelper of(String defaultMethodName) { return new InvokeHelper(null, defaultMethodName); } InvokeHelper();  InvokeHelper(ClassLoader classLoader);  InvokeHelper(ClassLoader classLoader, String defaultMethodName); static InvokeHelper of(String defaultMethodName); @Override void execute(Options options); @Override void init(); @Override Set<ConfigurationKey> getConfigurationKeys(); @Override void validate(HelperDefinition definition); }
InvokeHelper extends BasicHelper { public static InvokeHelper of(String defaultMethodName) { return new InvokeHelper(null, defaultMethodName); } InvokeHelper();  InvokeHelper(ClassLoader classLoader);  InvokeHelper(ClassLoader classLoader, String defaultMethodName); static InvokeHelper of(String defaultMethodName); @Override void execute(Options options); @Override void init(); @Override Set<ConfigurationKey> getConfigurationKeys(); @Override void validate(HelperDefinition definition); static final ConfigurationKey METHOD_CACHE_MAX_SIZE_KEY; }