Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Common approaches to using a HTML template are to:

Use a library like Mustache

...

Mustache is a fine templating library and liked by a lot of people. However I see these drawbacks:

  • 600 lines of code, 9 contributors for

    5

    20 line code problem

  • 9 contributors

  • It requires programmers to pick {{}} or {{{}}}

  • What parts of Mustache are good?

  • Offers caching of compiling templates

    • Is this premature optimization?

  • Optional special character escaping of some values - using triple
  • It’s therefore difficult to understand completely.

  • A lot bugs arise from people using Mustache and using {{ }} instead of {{{ }}}

    bracket notation.
  • Simple if and if not present solution - show what to print if something is not there.

  • Expressed in one file - good

  • What parts of Mustache are not good?

    • Lot of contributors for something for should be simple

  • ECMA literals also could be used as templating mechanism by themselves.

    But I don’t think they would work well.

    . The later format is required if you have data which includes & < and > characters. Not using the later form results in subtle bugs that only show up later.

  • It’s not bad compared to some templating frameworks but having conditional if/not support is starting down the path of building a bad language.

  • It has unnecessary features like template caching - which exchanges speed for memory usage and adds complexity - premature optimization