I am developing something like a CMS. I have articles which have templates. Articles are added on backend and I need to display them using templates (when I am rendering the article, I know which template to use). Since there will 10s of templates, I am trying to figure out what is the best way to store the templates and how to load the correct template according to loaded article. What I am considering:
- Storing metadata about a template on backend and building the template when I need it
- Storing the templates in application (need to build the app when new template is created)
- Storing raw templates on backend
- Having a component for each template and load them dynamically (too much overhead)
I am looking for an architectural and technological solution. I would love to go with option 1, but don't know how to build a template for article component. I would love to have just one component, which gets the article and just loads (builds) the needed template.
Angular2 RC5
EDIT:
template A: set A of css rules (blue text, caps for headlines), headline, paragraph, image, paragraph and a link somewhere else (inside the paragraph) template B: set B of css rules (red text, regular headlines), headline, carousel for images, one paragraph
{
"templateId": 1,
"title": "Article title",
"elements": [{
"text": "paragraph text"
}, {
"image": "http: //someurl.com"
}, {
"text": "another paragraph text"
}]
}