Thursday, 8 November 2018

Best templating language to render static template, with components-like structure

Hi /r/node !​We are building an application that allow the user to render then print a signage for a product in a store (the piece of paper with all of the product's information, I'm not sure of the English word for that).​The application fetch all the needed informations, and the template is then rendered in a Chromium who generate a PDF.​We have a solution already in production that uses EJS as the templating language. The issue is that as the templates grows, it's getting more and more complicate to maintain.​Here are our main restrictions :​We are opened in more than 70 countries (and thus, almost the same amount of locales to manage);We have country-specific element to display / hide / modify;​Based on these, I think that the best solution is the build the template with a set of minimalist components, so that the complexity of the template is reduced and we can make some country-specific choices without to much pain.​We kind of follow this philosophy already, by breaking our EJS template into many """components""" that we import. The issue is that the stylesheets are separated from those .ejs files.We have one common stylesheet for each format than one other specific by country and format. Eg: if we want to render a A3 template for Spain, we will import the common/stylesheet-A3.css file and the es/stylesheet-A3.css one.​The idea would be to have components that embeds stylesheets, and every country-specific fixes.​I've already search for solutions and came up with those ideas :​To develop a set of native Web Components :Even though I know that they are not wildly implemented nor used, I think that using this technology will allow us to create clean reusable components.​However, I don't know how we would be able to integrate them with our Node.js backend. Is there any template engine that will allow us to do so ?​Using Vue.js with SSR :I first was strongly against this solution because we are building a static template. But my love for this framework, the fact that all the team knows how to use it and the ease of kind of make me change my mind.​Stay with EJS templates ?We also can stay with the same technology buy add the stylesheet to the .ejs files ? I don't think that this is a suitable solution, and I don't know how we could make this work since we use Sass.​What do you guys think ? Did you already had to do a similar application ? And what are you thoughts on the three solutions ?​Thanks, and have a nice day :)

Submitted November 08, 2018 at 10:02AM by Thomas_Ferro

No comments:

Post a Comment