bind not substituting in a link element?

4 views
Skip to first unread message

Mark

unread,
Oct 15, 2009, 11:12:53 PM10/15/09
to Nitrogen Web Framework for Erlang
Assuming this context:

Data= [ [ "A", "Alink" ], ["B", "Blink" ]],
Map = [titleLabel@text, titleURL@text],

I can use a bind OK (substitution happens) using this snippet:

#bind { data=Data, map=Map, body=[ #label { id=titleLabel } ] }

but there's no substitution when I use this snippet:

#bind { data=Data, map=Map, body=[ #link { text=titleLabel, url =
titleURL } ] }

I think substitutions in the body of a bind should also occur inside
link elements. (If not, why not and how do I get the effect I'm
looking for?)

If I change to id=titleLabel above, then I get the label substituted
OK, but the URL is still not substituted...

thanks!


p.s.I put this up as a lighthouse ticket a while ago:
http://nitrogen.lighthouseapp.com/projects/21480/tickets/36-bind-doesnt-replace-terms-in-a-link-element
but it looks like the lighthouse keeper isn't at home any more...

Rusty Klophaus

unread,
Oct 16, 2009, 7:47:18 AM10/16/09
to nitro...@googlegroups.com
Hi Mark,

The bindings are of the form elementID@property. So with your original map, Nitrogen was looking for the 'titleLabel' element, and setting the text property (which worked), and then looking for the 'titleURL' element, which did not work because that element did not exist.

Give this code a shot. Notice that the map is looking for the 'titleLink' element in both cases. The first clause sets the text, the second clause sets the URL.

    Data= [ [ "A", "Alink" ], ["B", "Blink" ]], 
    Map = [titleLink@text, titleLink@url],
    #bind { data=Data, map=Map, body=[ #link { id=titleLink } ] }

Best,
Rusty

Mark

unread,
Oct 16, 2009, 8:15:30 PM10/16/09
to Nitrogen Web Framework for Erlang
Thanks - my mind was so set in a different preconception about how
bind worked that initially I thought your example must have contained
a typo! But I see how it works now, and indeed it does work.

thanks again -
Mark
Reply all
Reply to author
Forward
0 new messages