I like to announce my smalltalk port of mustache templates. 

Mustache is a popular templating engine that is supported in many programming 
languages. I know at least that is quite common to be used in javascript but 
see at the languages it supported yourself [1].

A basic usage is something like (just paste it to workspace after loading 
Mustache):

---
templateString := 'Hello {{name}},
this is {{templatingEngine}} for {{recipient}}.
{{# cheerUp }}
Have fun!
{{/  cheerUp }}'.

context := { 
        'name' -> 'pharo community'.
        'templatingEngine' -> 'mustache'.
        'recipient' -> 'you'.
        'cheerUp' -> true } asDictionary.
        
templateString asMustacheTemplate value: context
---

Context objects can be Dictionaries or regular objects. It is also easy to feed 
via json e.g. using NeoJSON 

templateString asMustacheTemplate value: (NeoJSONReader fromString: …)

I wrote a blog article about it and the usage in smaltlalk on my blog [2]. The 
code I have just released on smalltalkhub [3]. Documentation about the syntax 
to use is available under [4]. To load it do

Gofer it
        smalltalkhubUser: 'NorbertHartl' project: 'Mustache';
        configurationOf: 'Mustache';
        loadStable.

The code is not very old so there might be bugs (this is supposed to be the 
standard disclaimer). If you find something not working as expected just drop 
me a note. The engine produces at the moment more whitespaces than you can see 
in the examples. I need to figure out the rule first and will release a new 
version. Nevertheless I consider it useful by now. But you decide and hopefully 
give me feedback.

Norbert

[1] http://mustache.github.io/
[2] http://norbert.hartl.name/blog/2013/10/03/mustache-templates-for-smalltalk/
[3] http://smalltalkhub.com/#!/~NorbertHartl/Mustache
[4] http://mustache.github.io/mustache.5.html

Reply via email to