mustache bug?

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

mustache bug?

Peter Uhnak
Hi,

I'm using Mustache for Pharo, and according to mustache docs ( https://mustache.github.io/mustache.5.html ), when a key is not found, it should look into parents contexts.

However that does not seem to be the case:

str := '{{root}}
{{#items}}
{{root}}.{{name}}
{{/items}}'.

data := {
'root' -> 'ROOT'.
'items' -> {
{ 'name' -> 'first' } asDictionary.
{ 'name' -> 'second' } asDictionary.
}
} asDictionary.

(MustacheTemplate on: str) value: data.

I should get "ROOT.first", etc., but instead I get ".first", ".second".

Thanks,
Peter

Reply | Threaded
Open this post in threaded view
|

Re: mustache bug?

NorbertHartl
Where did you read this about the parent context? Maybe I’m blind to see it. That would explain why I didn’t see it when implementing it :)

Norbert

Am 13.08.2018 um 10:24 schrieb Peter Uhnák <[hidden email]>:

Hi,

I'm using Mustache for Pharo, and according to mustache docs ( https://mustache.github.io/mustache.5.html ), when a key is not found, it should look into parents contexts.

However that does not seem to be the case:

str := '{{root}}
{{#items}}
{{root}}.{{name}}
{{/items}}'.

data := {
'root' -> 'ROOT'.
'items' -> {
{ 'name' -> 'first' } asDictionary.
{ 'name' -> 'second' } asDictionary.
}
} asDictionary.

(MustacheTemplate on: str) value: data.

I should get "ROOT.first", etc., but instead I get ".first", ".second".

Thanks,
Peter


Reply | Threaded
Open this post in threaded view
|

Re: mustache bug?

Sven Van Caekenberghe-2


> On 13 Aug 2018, at 13:59, Norbert Hartl <[hidden email]> wrote:
>
> Where did you read this about the parent context? Maybe I’m blind to see it. That would explain why I didn’t see it when implementing it :)

Search for parent in http://mustache.github.io/mustache.5.html

Variables
The most basic tag type is the variable. A {{name}} tag in a basic template will try to find the name key in the current context. If there is no name key, the parent contexts will be checked recursively. If the top context is reached and the name key is still not found, nothing will be rendered.

> Norbert
>
>> Am 13.08.2018 um 10:24 schrieb Peter Uhnák <[hidden email]>:
>>
>> Hi,
>>
>> I'm using Mustache for Pharo, and according to mustache docs ( https://mustache.github.io/mustache.5.html ), when a key is not found, it should look into parents contexts.
>>
>> However that does not seem to be the case:
>>
>> str := '{{root}}
>> {{#items}}
>> {{root}}.{{name}}
>> {{/items}}'.
>>
>> data := {
>> 'root' -> 'ROOT'.
>> 'items' -> {
>> { 'name' -> 'first' } asDictionary.
>> { 'name' -> 'second' } asDictionary.
>> }
>> } asDictionary.
>>
>> (MustacheTemplate on: str) value: data.
>>
>> I should get "ROOT.first", etc., but instead I get ".first", ".second".
>>
>> Thanks,
>> Peter
>>
>


Reply | Threaded
Open this post in threaded view
|

Re: mustache bug?

NorbertHartl
Hmmm. To easy for me to figure out :) 


Norbert

Am 13.08.2018 um 14:06 schrieb Sven Van Caekenberghe <[hidden email]>:



On 13 Aug 2018, at 13:59, Norbert Hartl <[hidden email]> wrote:

Where did you read this about the parent context? Maybe I’m blind to see it. That would explain why I didn’t see it when implementing it :)

Search for parent in http://mustache.github.io/mustache.5.html

Variables
The most basic tag type is the variable. A {{name}} tag in a basic template will try to find the name key in the current context. If there is no name key, the parent contexts will be checked recursively. If the top context is reached and the name key is still not found, nothing will be rendered.

Norbert

Am 13.08.2018 um 10:24 schrieb Peter Uhnák <[hidden email]>:

Hi,

I'm using Mustache for Pharo, and according to mustache docs ( https://mustache.github.io/mustache.5.html ), when a key is not found, it should look into parents contexts.

However that does not seem to be the case:

str := '{{root}}
{{#items}}
{{root}}.{{name}}
{{/items}}'.

data := {
'root' -> 'ROOT'.
'items' -> {
{ 'name' -> 'first' } asDictionary.
{ 'name' -> 'second' } asDictionary.
}
} asDictionary.

(MustacheTemplate on: str) value: data.

I should get "ROOT.first", etc., but instead I get ".first", ".second".

Thanks,
Peter