Stef,

{{# …} opens a section that can be used to do nested operation. If the value of 
number is a collection the section is evaluated for every element in the value. 
#(1 2 3) is a collection of size 3 and '1 2 3' is a collection of size 5 hence 
the output. 
A common use case for templates would be something like

{
   'number' -> {
        'value' -> 1.
        'value' -> 2.
        'value' -> 3 } asDictionary
} asDictionary

Then you can use a template of 

{{#number}}
        value is {{value}}
{{/number}}

Norbert

Am 13.07.2014 um 23:33 schrieb stepharo <[email protected]>:

> Hi Norbert
> 
> I'm improving the doc. I added some text on section and others..
> And on list with collection I have the following behavior and I do not 
> understand why on string.
> 
> | templateString context |
> templateString := 'Shown.
> {{#number}}
>   Shown too!
> {{/number}}'.
> context := { 'number' -> #(1 2 3) } asDictionary.
> (MustacheTemplate on: templateString) value: context  'Shown.
> 
>   Shown too!
> 
>   Shown too!
> 
>   Shown too!
> '
>  
> 
> 
> | templateString context |
> templateString := 'Shown.
> {{#number}}
>   Shown too!
> {{/number}}'.
> context := { 'number' -> '1 2 3' } asDictionary.
> (MustacheTemplate on: templateString) value: context 
>  'Shown.
> 
>   Shown too!
> 
>   Shown too!
> 
>   Shown too!
> 
>   Shown too!
> 
>   Shown too!
> '
> 
> 
> 
> 
> On 11/7/14 10:53, Norbert Hartl wrote:
>> 
>> Am 11.07.2014 um 10:43 schrieb stepharo <[email protected]>:
>> 
>>> Hi guys
>>> 
>>> I would like to experiment with template for a small web project I have (my 
>>> web page) and
>>> I would like to try mustache. Is there any tutorial? doc?
>>> I know that "jose maria aguerra" wrote a tutorial but I cannot find it 
>>> anymore.
>> 
>> http://norbert.hartl.name/blog/2013/10/03/mustache-templates-for-smalltalk/
>> 
>> Norbert
>> 
> 

Reply via email to