Snippets (Include templates in others)

Maybe to better understand it, let me start with a use case:

Let’s say, for example, you have an online store that sells 50 different widgets. You like to provide your customers with a description of the widget they purchased, so you make a template for each widget. However, you also like to include your company’s branding in the email (a table with background color, your logo, etc), a column down the right hand side with links to a few popular articles, and a footer with links to your website, privacy policy, etc. Now let’s say you want to modify a side link, add a link in the footer, and change the background color of one of the table cells. This now requires meticulously going through each of the 50 templates and modifying each one and hoping you don’t make a mistake.

There needs to be a way around this. I have a few ideas:

  1. Allow templates to extend other templates. Maybe something similar to Laravel’s blade templating engine. You have a main layout template which says it contains a “content” section. Then in a template that extends the main template you add a content section and it will be inserted at the correct position in the main template.

  2. A simpler version of the above where in a template you simply do “{{include otherTemplate}}” and it includes that one at that point.

  3. Allow templates to be added to the email without deleting the current content. This way the user could define a main layout template, add it to a blank email, click on the desired position where they want another template to be inserted and insert it. This is how the Thunderbird Quicktext extension handles it.

  4. Hopefully this doesn’t get confusing to users, but add something called “snippets”. The user defines a template for the layout, and only one template can be used per email (exactly like now), but they can also define small snippets of text or HTML to be inserted anywhere they want in an email, whether a template has been used or not, and any number of snippets can be inserted into a single email. This would benefit from being able to separate your presentation layer (template) from your content layer (snippets).


(Originally posted by multiwebinc on GitHub.)

Duplicate: