rocker icon indicating copy to clipboard operation
rocker copied to clipboard

nested templates

Open midi-foot-controller opened this issue 6 years ago • 2 comments

I try to call a optional nested templates like

@with (templateName = model.getNestedTemplateName("SAMPLE") {
   @if (null != templateName) {
      @Rocker.template(templateName, model)
   }
}

My model contains a method

public String getNestedTemplateName(final String componentName)
{
  if ("SAMPLE".equals(componentName)) {
     return (SampleTemplate.getTemplatePackageName().replace(".", "/") + "/" + SampleTemplate.getTemplateName());
  }
   return null;
}

this is quite lengthy.. Is it possible to add a method "getFullTemplateName" which returns the complete name to the generated templates?

Thanks Jens

midi-foot-controller avatar Jun 15 '19 07:06 midi-foot-controller

What prevents you from calling the template directly?

@import package.SampleTemplate
@args(...)

@SampleTemplate.template(model)

bendem avatar Jul 24 '19 09:07 bendem

I'm curious, what's your use case for having templates that could not exist?

bendem avatar Jul 24 '19 09:07 bendem