On Wed, Nov 11, 2009 at 11:21 AM, aw <anth...@whitford.com> wrote:

>
> OK, your suggestion definitely makes the snippet code more readable,
> but I fear I didn't make my point clear because the snippet code still
> is highly coupled with the view layout.
>

If this was a MVC type framework, I think you're point would be valid.  But
it isn't a MVC framework.  The snippet is tightly coupled to the xhtml,
because it's the dynamic part of the xhtml.

The best way to mitigate these kinds of changes is to design the UI first,
then build the snippets.   That way, you're not rearranging as often.
See this article for a better understanding:
http://wiki.liftweb.net/index.php?title=Lift_View_First


> Imagine that I want to change my view from this:
>
> <a href="next">
>    <span class="name">name</span>
>    <span class="comment">description</span>
>    <span class="arrow"/>
> </a>
>
> to this:
>
> <span class="name">name</span>
> <span class="comment">description</span>
> <a href="next">
>     <span class="arrow"/>
> </a>
>
> This would mean that I need to change my template from:
>
> <b1:link>
>    <span class="name"><b2:name/></span>
>    <span class="comment"><b2:description/></span>
>    <span class="arrow"/>
> </b1:link>
>
> to this:
>
> <span class="name"><b:name/></span>
> <span class="comment"><b:description/></span>
> <b:link>
>    <span class="arrow"/>
> </b:link>
>
> And then I need to update my code from:
>
> bind("b1", xhtml",
>   "link" -> kids => SHtml.link("next", () => clicked(b),
>    bind("b2", kids, "name" -> b.name.is, "description" ->
> b.description.is
> )))
>
> to something like this:
>
> bind("b", xhtml",
>   "name" -> b.name.is,
>   "description" -> b.description.is,
>   "link" -> kids => SHtml.link("next", () => clicked(b))
> )))
>
>
> My complaint is that reorganizing the view is tending to require code
> changes at the snippet level.  And that just doesn't seem right to me.
>
> At first, I thought that I could leverage the recursive nature of
> snippets.  In other words, I thought I could avoid the b1 and b2
> binding keys and simply use b, then when the first round contained
> more b variables to bind, it would recurse.  Alas, this didn't work
> (I'm sorry, but I don't recall the error message).  But this was what
> I was thinking:
>
> <b:link>
>    <span class="name"><b:name/></span>
>    <span class="comment"><b:description/></span>
>    <span class="arrow"/>
> </b:link>
>
> or this:
>
> <span class="name"><b:name/></span>
> <span class="comment"><b:description/></span>
> <b:link>
>    <span class="arrow"/>
> </b:link>
>
> and the code would remain this:
>
> bind("b", xhtml",
>   "name" -> b.name.is,
>   "description" -> b.description.is,
>   "link" -> kids => SHtml.link("next", () => clicked(b))
> )))
>
>
> >
>


-- 
James A Barrows

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to