Uploaded image for project: 'Magnolia Standard Templating Kit (closed)'
  1. Magnolia Standard Templating Kit (closed)
  2. MGNLSTK-577

Make it configurable what classes are included in the freemarker template rendering context

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Major Major
    • 1.3
    • 1.2.3
    • templates

      It would be nice to be able to register classes under the template-renderer en paragraph-renderer configurations, so that those classes would be added to the template rendering context.

      STKTemplateRenderer could get a Map property like 'classesToInclude'
      it would be nice if modules/standard-templating-kit/template-renderers/stk would be watched, and new classes would be added on the fly through content2bean. STKTemplateRenderer would have to propagate this map to FreemarkerHelper

      you could do something like this in FreemarkerHelper:

      TemplateHashModel staticModels = wrapper.getStaticModels();
              try {
                  for (String name : classesToInclude.keySet()) {
                      TemplateHashModel model = (TemplateHashModel) staticModels.get(classesToInclude.get(name));
                      map.put(name, model);
                  }
              } catch (TemplateModelException e) {
                  e.printStackTrace();
              }
      

      That way all static methods of the class are available.

        Acceptance criteria

              gjoseph Magnolia International
              ebunders Ernst Bunders
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved: