geli-lms / geli

geli is an open source e-learning platform
Apache License 2.0
153 stars 70 forks source link

Introduce a (mail-) templating #78

Open aeimer opened 7 years ago

aeimer commented 7 years ago

User Story

As a:

Programmer

I want:

to have a templating engine in the backend

so that:

I can easier and cleaner create and maintain templates for e.g. (html) mails

Storypoints:

?

Acceptance criteria:

Additional info:

The module mini-template-engine looks pretty good for this task.

Some kind of example code may be this:

class Templating {
  private $wrapper = '<div>add here some cool styled css/html stuff<div class="content">[[CONTENT]]</div></div>';
  private $activation = 'Hi {user.name}, please click {activationlink}. CU';

  public static function render($template, $html = false, array $attributes) {
    // todo check if template exists
    $input = $template_content; // MAGIC: this is the content of eg $activation for $template = 'activation'
    if ($html) {
      strreplace('[[CONTENT]]', $wrapper, $input);
    }
    $output = TinyTmpl.render($input, $attributes);
    return $output;
  }
}

but instead of getting the content from the variables we should read them from the template-files.

grosspersky commented 7 years ago

An other possible candidate for this task could be https://github.com/crocodilejs/node-email-templates

Some predefined templates can be found here: https://github.com/mailgun/transactional-email-templates