Skip to content

Have 1 consistent solution for templates #721

Closed

Description

@jvherweg

Current state

We currently have several very similar interfaces/classes related to using template files:

TemplateEngine with implementation HandleBarsTemplateEngine is used for pod provisioning. Here the interface takes as input a template string and a Dict<string> for the values to fill into the template using handlebars.

TemplateRenderer<T> with implementation EjsTemplateRenderer<T> takes a file path in the constructor which points to a template file. Its handle function then takes as input an object of type T which is sent to ejs together with the file path.

Additionally, there is also a RenderHandler<T> interface with implementation RenderEjsHandler<T> which is very similar to the EjsTemplateRenderer from above, except this one also takes an HttpResponse as handle parameter and then immediately sends the rendered template as html to that response object.

Suggested solution

Use the same template engine everywhere to reduce dependencies. Probably handlebars, but since our templates are quite simple it doesn't matter that much.

Have 1 interface for a template renderer/engine. I would suggest a combination of the two: a handler that takes a template string and an object of type T as template properties. This way we don't need to instantiate a renderer for every template file.

To still support linking to template file paths I would suggest also having a simple wrapped renderer that takes as input a template file path instead, reads that out and then sends it to the wrapper renderer.

We could then also remove the EjsTemplateRenderer and instead have a TemplateRenderHandler that calls the new handler from above instead of calling a rendering engine itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions