Mustache and section

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Mustache and section

HilaireFernandes
Hello,

While iterating within a Mustache section is it possible to refer to a
tag defined out of the list.

For example, is it possible to do so:

templateString := 'A list of numbers
{{#list}}
Number {{label}} : {{number}}     <= #label in section
{{/list}}'.

context := {
   'label' -> 'fine.
   'list' -> {
      { 'number' -> 1 } asDictionary.
      { 'number' -> 2 } asDictionary.
    }
} asDictionary


to get output as:
'A list of numbers
Number fine: 1
Number fine: 2
'

So far in my attempt the #label tag is not processed.

Am I interpreting something wrongly?

Thanks

Hilaire

--
Dr. Geo
http://drgeo.eu


Reply | Threaded
Open this post in threaded view
|

Re: Mustache and section

NorbertHartl


> Am 02.12.2016 um 15:56 schrieb Hilaire <[hidden email]>:
>
> Hello,
>
> While iterating within a Mustache section is it possible to refer to a
> tag defined out of the list.
>
> For example, is it possible to do so:
>
> templateString := 'A list of numbers
> {{#list}}
> Number {{label}} : {{number}}     <= #label in section
> {{/list}}'.
>
> context := {
>   'label' -> 'fine.
>   'list' -> {
>      { 'number' -> 1 } asDictionary.
>      { 'number' -> 2 } asDictionary.
>    }
> } asDictionary
>
>
> to get output as:
> 'A list of numbers
> Number fine: 1
> Number fine: 2
> '
>
> So far in my attempt the #label tag is not processed.
>
> Am I interpreting something wrongly?
>
No, what you want is not possible. To achieve it you should copy label into the elements of the list section.

Norbert
> Thanks
>
> Hilaire
>
> --
> Dr. Geo
> http://drgeo.eu
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Mustache and section

HilaireFernandes
Okay.
Indeed, my bypass was to copy the label in the list.

Thank you for your answer.

Hilaire

Le 04/12/2016 à 08:14, Norbert Hartl a écrit :
>> So far in my attempt the #label tag is not processed.
>> >
>> > Am I interpreting something wrongly?
>> >
> No, what you want is not possible. To achieve it you should copy label into the elements of the list section.
>
> Norbert

--
Dr. Geo
http://drgeo.eu


Reply | Threaded
Open this post in threaded view
|

Re: Mustache and section

NorbertHartl
Ok. I think about that again. It might be a useful thing to have although not supported IMHO by other mustache implementations.

Norbert

> Am 04.12.2016 um 18:19 schrieb Hilaire <[hidden email]>:
>
> Okay.
> Indeed, my bypass was to copy the label in the list.
>
> Thank you for your answer.
>
> Hilaire
>
>> Le 04/12/2016 à 08:14, Norbert Hartl a écrit :
>>>> So far in my attempt the #label tag is not processed.
>>>>
>>>> Am I interpreting something wrongly?
>>>>
>> No, what you want is not possible. To achieve it you should copy label into the elements of the list section.
>>
>> Norbert
>
> --
> Dr. Geo
> http://drgeo.eu
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Mustache and section

Stephane Ducasse-3
having a nicer mustache can be cool :)

On Mon, Dec 5, 2016 at 6:25 AM, Norbert Hartl <[hidden email]> wrote:
Ok. I think about that again. It might be a useful thing to have although not supported IMHO by other mustache implementations.

Norbert

> Am 04.12.2016 um 18:19 schrieb Hilaire <[hidden email]>:
>
> Okay.
> Indeed, my bypass was to copy the label in the list.
>
> Thank you for your answer.
>
> Hilaire
>
>> Le 04/12/2016 à 08:14, Norbert Hartl a écrit :
>>>> So far in my attempt the #label tag is not processed.
>>>>
>>>> Am I interpreting something wrongly?
>>>>
>> No, what you want is not possible. To achieve it you should copy label into the elements of the list section.
>>
>> Norbert
>
> --
> Dr. Geo
> http://drgeo.eu
>
>



Reply | Threaded
Open this post in threaded view
|

Re: Mustache and section

NorbertHartl
I agree. But there is also a point in sharing mustache templates between  different runtimes. Altering mustache does not make it very mustache anymore. And it will make it slower. I put that on my ever growing list of things to do. Maybe a switch could bring the best of both worlds.

Norbert

Am 05.12.2016 um 16:24 schrieb Stephane Ducasse <[hidden email]>:

having a nicer mustache can be cool :)

On Mon, Dec 5, 2016 at 6:25 AM, Norbert Hartl <[hidden email]> wrote:
Ok. I think about that again. It might be a useful thing to have although not supported IMHO by other mustache implementations.

Norbert

> Am 04.12.2016 um 18:19 schrieb Hilaire <[hidden email]>:
>
> Okay.
> Indeed, my bypass was to copy the label in the list.
>
> Thank you for your answer.
>
> Hilaire
>
>> Le 04/12/2016 à 08:14, Norbert Hartl a écrit :
>>>> So far in my attempt the #label tag is not processed.
>>>>
>>>> Am I interpreting something wrongly?
>>>>
>> No, what you want is not possible. To achieve it you should copy label into the elements of the list section.
>>
>> Norbert
>
> --
> Dr. Geo
> http://drgeo.eu
>
>



Reply | Threaded
Open this post in threaded view
|

Re: Mustache and section

Stephane Ducasse-3
You mean that you would like to invent a much better mustache. 
We could keep mustache as it is and invent Beard or rouquaflette :)

On Mon, Dec 5, 2016 at 12:35 PM, Norbert Hartl <[hidden email]> wrote:
I agree. But there is also a point in sharing mustache templates between  different runtimes. Altering mustache does not make it very mustache anymore. And it will make it slower. I put that on my ever growing list of things to do. Maybe a switch could bring the best of both worlds.

Norbert

Am 05.12.2016 um 16:24 schrieb Stephane Ducasse <[hidden email]>:

having a nicer mustache can be cool :)

On Mon, Dec 5, 2016 at 6:25 AM, Norbert Hartl <[hidden email]> wrote:
Ok. I think about that again. It might be a useful thing to have although not supported IMHO by other mustache implementations.

Norbert

> Am 04.12.2016 um 18:19 schrieb Hilaire <[hidden email]>:
>
> Okay.
> Indeed, my bypass was to copy the label in the list.
>
> Thank you for your answer.
>
> Hilaire
>
>> Le 04/12/2016 à 08:14, Norbert Hartl a écrit :
>>>> So far in my attempt the #label tag is not processed.
>>>>
>>>> Am I interpreting something wrongly?
>>>>
>> No, what you want is not possible. To achieve it you should copy label into the elements of the list section.
>>
>> Norbert
>
> --
> Dr. Geo
> http://drgeo.eu
>
>




Reply | Threaded
Open this post in threaded view
|

Re: Mustache and section

NorbertHartl
I want to keep mustache to work as the other mustache implementations.
I agree choosing a different name for an enhanced version would be feasible. That happened in the javascript world several times. One example is handlebars. Much better is not that easy. In most implementations I know better is something like adding poor duplicates of functionalities of your programming language to the template engine. Does not work in the end. So better you need to prove if this one is not good enough.

Norbert

Am 06.12.2016 um 03:24 schrieb Stephane Ducasse <[hidden email]>:

You mean that you would like to invent a much better mustache. 
We could keep mustache as it is and invent Beard or rouquaflette :)

On Mon, Dec 5, 2016 at 12:35 PM, Norbert Hartl <[hidden email]> wrote:
I agree. But there is also a point in sharing mustache templates between  different runtimes. Altering mustache does not make it very mustache anymore. And it will make it slower. I put that on my ever growing list of things to do. Maybe a switch could bring the best of both worlds.

Norbert

Am 05.12.2016 um 16:24 schrieb Stephane Ducasse <[hidden email]>:

having a nicer mustache can be cool :)

On Mon, Dec 5, 2016 at 6:25 AM, Norbert Hartl <[hidden email]> wrote:
Ok. I think about that again. It might be a useful thing to have although not supported IMHO by other mustache implementations.

Norbert

> Am 04.12.2016 um 18:19 schrieb Hilaire <[hidden email]>:
>
> Okay.
> Indeed, my bypass was to copy the label in the list.
>
> Thank you for your answer.
>
> Hilaire
>
>> Le 04/12/2016 à 08:14, Norbert Hartl a écrit :
>>>> So far in my attempt the #label tag is not processed.
>>>>
>>>> Am I interpreting something wrongly?
>>>>
>> No, what you want is not possible. To achieve it you should copy label into the elements of the list section.
>>
>> Norbert
>
> --
> Dr. Geo
> http://drgeo.eu
>
>




Reply | Threaded
Open this post in threaded view
|

Re: Mustache and section

Damien Pollet-2
In reply to this post by Stephane Ducasse-3

On 5 December 2016 at 21:54, Stephane Ducasse <[hidden email]> wrote:
You mean that you would like to invent a much better mustache. 
We could keep mustache as it is and invent Beard or rouquaflette :)

On Mon, Dec 5, 2016 at 12:35 PM, Norbert Hartl <[hidden email]> wrote:
I agree. But there is also a point in sharing mustache templates between  different runtimes. Altering mustache does not make it very mustache anymore. And it will make it slower. I put that on my ever growing list of things to do. Maybe a switch could bring the best of both worlds.

Norbert

Am 05.12.2016 um 16:24 schrieb Stephane Ducasse <[hidden email]>:

having a nicer mustache can be cool :)

On Mon, Dec 5, 2016 at 6:25 AM, Norbert Hartl <[hidden email]> wrote:
Ok. I think about that again. It might be a useful thing to have although not supported IMHO by other mustache implementations.

Norbert

> Am 04.12.2016 um 18:19 schrieb Hilaire <[hidden email]>:
>
> Okay.
> Indeed, my bypass was to copy the label in the list.
>
> Thank you for your answer.
>
> Hilaire
>
>> Le 04/12/2016 à 08:14, Norbert Hartl a écrit :
>>>> So far in my attempt the #label tag is not processed.
>>>>
>>>> Am I interpreting something wrongly?
>>>>
>> No, what you want is not possible. To achieve it you should copy label into the elements of the list section.
>>
>> Norbert
>
> --
> Dr. Geo
> http://drgeo.eu
>
>