[ANN] Mustache templates
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
Excellent! Mustache is broadly used in the JS world (both web and node). I wonder what do you use it for. I'd love an extension to the syntax to deal with JSON like structures (it is scalars, arrays and dictionaries). :) Esteban A. Maringolo 2013/10/3 Norbert Hartl <norbert@hartl.name>:
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
Am 03.10.2013 um 22:42 schrieb Esteban A. Maringolo <emaringolo@gmail.com>:
Excellent!
Mustache is broadly used in the JS world (both web and node). I wonder what do you use it for.
At the moment mostly for generating SOAP requests :) But I often have template-like stuff for what I'm hacking something stupid together. I thought it should come to an end.
I'd love an extension to the syntax to deal with JSON like structures (it is scalars, arrays and dictionaries). :)
What have those to do with the syntax? Can you elaborate on that? Norbert
Esteban A. Maringolo
2013/10/3 Norbert Hartl <norbert@hartl.name>:
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
So basically you have a Mustache based XML template to consume/produce SOAP requests. Good idea :) Regarding the JS syntax, Several times I found myself writing a lot of dictionary like expressions that got converted into Dictionaries and then to JSON strings, so I daydreamed about having something as close to JSON syntax as possible (it is, JS syntax) embedded in the smalltalk code. The analogous to the {exp1. exp2} syntax, but to create "hash maps" (it is, Dictionaries) right from the syntax. Regards! Esteban A. Maringolo 2013/10/3 Norbert Hartl <norbert@hartl.name>:
Am 03.10.2013 um 22:42 schrieb Esteban A. Maringolo <emaringolo@gmail.com>:
Excellent!
Mustache is broadly used in the JS world (both web and node). I wonder what do you use it for.
At the moment mostly for generating SOAP requests :) But I often have template-like stuff for what I'm hacking something stupid together. I thought it should come to an end.
I'd love an extension to the syntax to deal with JSON like structures (it is scalars, arrays and dictionaries). :)
What have those to do with the syntax? Can you elaborate on that?
Norbert
Esteban A. Maringolo
2013/10/3 Norbert Hartl <norbert@hartl.name>:
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
Did you look at STON ? Stef On Oct 4, 2013, at 12:55 AM, Esteban A. Maringolo <emaringolo@gmail.com> wrote:
So basically you have a Mustache based XML template to consume/produce SOAP requests. Good idea :)
Regarding the JS syntax, Several times I found myself writing a lot of dictionary like expressions that got converted into Dictionaries and then to JSON strings, so I daydreamed about having something as close to JSON syntax as possible (it is, JS syntax) embedded in the smalltalk code. The analogous to the {exp1. exp2} syntax, but to create "hash maps" (it is, Dictionaries) right from the syntax.
Regards!
Esteban A. Maringolo
2013/10/3 Norbert Hartl <norbert@hartl.name>:
Am 03.10.2013 um 22:42 schrieb Esteban A. Maringolo <emaringolo@gmail.com>:
Excellent!
Mustache is broadly used in the JS world (both web and node). I wonder what do you use it for.
At the moment mostly for generating SOAP requests :) But I often have template-like stuff for what I'm hacking something stupid together. I thought it should come to an end.
I'd love an extension to the syntax to deal with JSON like structures (it is scalars, arrays and dictionaries). :)
What have those to do with the syntax? Can you elaborate on that?
Norbert
Esteban A. Maringolo
2013/10/3 Norbert Hartl <norbert@hartl.name>:
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
Very nice. Thanks for making it available! --- Philippe Back Dramatic Performance Improvements Mob: +32(0) 478 650 140 | Fax: +32 (0) 70 408 027 Mail:phil@highoctane.be | Web: http://philippeback.eu Blog: http://philippeback.be | Twitter: @philippeback Youtube: http://www.youtube.com/user/philippeback/videos High Octane SPRL rue cour Boisacq 101 | 1301 Bierges | Belgium Pharo Consortium Member - http://consortium.pharo.org/ Featured on the Software Process and Measurement Cast - http://spamcast.libsyn.com Sparx Systems Enterprise Architect and Ability Engineering EADocX Value Added Reseller On Thu, Oct 3, 2013 at 11:32 PM, Norbert Hartl <norbert@hartl.name> wrote:
Am 03.10.2013 um 22:42 schrieb Esteban A. Maringolo <emaringolo@gmail.com
:
Excellent!
Mustache is broadly used in the JS world (both web and node). I wonder what do you use it for.
At the moment mostly for generating SOAP requests :) But I often have template-like stuff for what I'm hacking something stupid together. I thought it should come to an end.
I'd love an extension to the syntax to deal with JSON like structures (it is scalars, arrays and dictionaries). :)
What have those to do with the syntax? Can you elaborate on that?
Norbert
Esteban A. Maringolo
2013/10/3 Norbert Hartl <norbert@hartl.name>:
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
participants (4)
-
Esteban A. Maringolo -
Norbert Hartl -
phil@highoctane.be -
Stéphane Ducasse