Skip to content

Instantly share code, notes, and snippets.

@mojombo
Created December 23, 2009 05:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mojombo/262328 to your computer and use it in GitHub Desktop.
Save mojombo/262328 to your computer and use it in GitHub Desktop.
Just a simple demonstration of how to use my soon-to-be-released mustache.erl library. Mustaches forever!
-module(simple).
-compile(export_all).
name() ->
"Tom".
value() ->
10000.
taxed_value() ->
value() - (value() * 0.4).
in_ca() ->
true.
%%---------------------------------------------------------------------------
start() ->
code:add_patha(".."),
Output = mustache:render(simple, "simple.mustache"),
io:format(Output, []).
Hello {{name}}
You have just won ${{value}}!
{{#in_ca}}
Well, ${{ taxed_value }}, after taxes.
{{/in_ca}}
Hello Tom
You have just won $10000!
Well, $6000.00, after taxes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment