1

I want to know the name of the parameters that are in a template without having the helpers, I can't seem to find from neither Handlebars nor Template a natural way to do this. I had to do it manually but maybe I am missing how to do it?

Handlebars hb = newHandlebars();
Template template = hb.compileInline(input);

Set<String> variableNames = new HashSet<String>(template.collectReferenceParameters());

List<String> tagNames = template.collect(TagType.values());
for (String tagName : tagNames) {
  if (hb.helper(tagName) == null) {
    variableNames.add(tagName);
  }
}
imTachu
  • 3,759
  • 4
  • 29
  • 56
  • Doesn't TagType.VAR fit your needs? Otherwise if you also want to collect sections and other of tags I suspect your have to indeed filter out helpers (use lambdas for brevity if possible). But if you really need a "natural", get in touch with the developers, perhaps they can add a collect method which accepts a Predicate. – AndreLDM Mar 24 '17 at 03:15
  • yeah, I would like just a _natural_ way of getting them, will ask for the feature :) – imTachu Apr 26 '17 at 14:41

0 Answers0