Norbert, Dot notation solves the issue and [1] works as expected. =[1]======== '{{#twitter}} <tr> <td class="mdl-data-table__cell--non-numeric"> <b>Twitter</b></td> <td class="mdl-data-table__cell--non-numeric"> <a href="https://twitter.com/{{.}}"> {{.}}</a></td> </tr> {{/twitter}}' asMustacheTemplate value: { #twitter -> '@offrayLC' } asDictionary =========== Thanks for the work on Mustache and the Enterprise Pharo chapter. Is a really good written book (so far I have read the Mustache, Teapot and ZnServer chapters). I wonder if there is a place for extensions and clarifications of this book in its online version, for example, regarding dot notation. Cheers, Offray On 29/05/17 16:48, Norbert Hartl wrote:
Offray,
I think I didn't get what you want at first. When using a section in mustache {{#twitter}} then the object value of the key twitter becomes the current context. Every property is resolved relative to this current context. If you want to use the current context itself as value you can use the dot notation {{ . }}. There was a problem when this context itself is a string. I solved that a year ago but I've seen that the newest configuration was not in the MetaRepo. It means if you loaded mustache from the catalog then you loaded a slightly older version that doesn't include that fix. I've update all MetaRepos from pharo4 to pharo6 for the newest configuration. If you load it now it should work.
hope that helps,
Norbert
Am 29.05.2017 um 17:15 schrieb Offray Vladimir Luna Cárdenas <offray.luna@mutabit.com>:
Yes I can share the data. Please load Brea project from [1] and do:
=========
| testUser | testUser := BreaMember new createTestUser. testUser html
=========
[1] http://smalltalkhub.com/#!/~Offray/Brea
You will see that the twitter portion of the row is showed, but without any actual data inside. You can also try this:
========= '{{#twitter}} <tr> <td class="mdl-data-table__cell--non-numeric"><b>Twitter</b></td> <td class="mdl-data-table__cell--non-numeric"> <a href="https://twitter.com/{{twitter}}">{{twitter}}</a></td> </tr> {{/twitter}}' asMustacheTemplate value: { #twitter -> '@offrayLC' } asDictionary =========
with the same behavior.
I think that the proper output will be the row showed with the data inside filled.
Let me know how can I help to debug this.
Thanks,
Offray
On 29/05/17 09:26, Norbert Hartl wrote:
To clarify. If the object you inject has a value which either does not contain the key twitter or it does container the key twitter but its value is nil then the section won't be shown.
'{{#twitter}} <tr> <td class="mdl-data-table__cell--non-numeric"><b>Twitter</b></td> <td class="mdl-data-table__cell--non-numeric"> <a href="https://twitter.com/{{twitter}}">{{twitter}}</a></td> </tr> {{/twitter}}' asMustacheTemplate value: { #twitter -> nil } asDictionary
gives empty string in my case.
Norbert
Am 29.05.2017 um 16:20 schrieb Norbert Hartl <norbert@hartl.name>:
Can you show some data you are injecting? It should work as you expect it.
Norbert
Am 29.05.2017 um 15:26 schrieb Offray Vladimir Luna Cárdenas <offray.luna@mutabit.com>:
Hi,
I'm using Mustache for a project to build a dynamic distributed web site generator for public & open data, backed by Fossil and using Material Design Lite. I have a template like this:
========
{{#twitter}} <tr> <td class="mdl-data-table__cell--non-numeric"><b>Twitter</b></td> <td class="mdl-data-table__cell--non-numeric"> <a href="https://twitter.com/{{twitter}}">{{twitter}}</a></td> </tr> {{/twitter}}
========
that is mean to show or hide a row in a table, depending on if Twitter data for a profile is found in a user profile. When the profile doesn't have twitter data, the row is hidden, as supposed, and when it has, the row is shown, but without any actual twitter data. What I'm missing? Should I use partials in this case and how?
Thanks,
Offray