ErlangInside

30

Dic

Mustache: GitHub’s Framework Agnostic Templating Ported to Erlang

Mustache is an Erlang port of the Ruby framework of the same name, originally written by Chris Wanstrath, one of the founders of GitHub. A powerful feature of this type of framework is the ability to write a ‘template’ that you could use in a Rails application and then reuse in an Erlang application with no changes to that file. The ‘view’ (which in MVC terms is more like the ‘controller’) would have to be re-written, but this would greatly simplify the work of porting an application, OR simply running a part of application in a different framework for performance reasons.

Chris calls Mustache “a replacement for your views.” Instead of views consisting of ERB or HAML with random helpers and arbitrary logic, your views are broken into two parts: a Ruby class (or Erlang module) and an HTML template.

They call the Ruby/Erlang part the “view” and the HTML template the “template.”

All your logic, decisions, and code is contained in your view. All your markup is contained in your template. The template does nothing but reference methods in your view.

This strict separation makes it easier to write clean templates, easier to test your views, and more fun to work on your app’s front end.

Check it out!

Comentarios recientes