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 |
> 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? > Norbert > Thanks > > Hilaire > > -- > Dr. Geo > http://drgeo.eu > > |
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 |
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 > > |
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. |
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
|
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 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
|
In reply to this post by Stephane Ducasse-3
https://github.com/zalando/beard is in Scala :p On 5 December 2016 at 21:54, Stephane Ducasse <[hidden email]> wrote:
|
Free forum by Nabble | Edit this page |