On Tue, Aug 25, 2009 at 1:21 PM, george <[email protected]> wrote:

>
> <lift:Licenses.index>
>
>        <h3><l:type /></h3>
>
>        <table>
>                        <lift:Ratings.index>
>                        <tr>
>              <td><r:rating /></td>
>                        </tr>
>                        </lift:Ratings.index>
>        </table>
>
> </lift:Licenses.index>
>
>
> and if so..
>
> can I pass a parameter to the inner Ratings.index snippet - e.g the ID
> of the current license object being processed - so that the
> Ratings.index function can use it to find the ratings.
>
> the idea being that this way I could re-use my existing Rating snippet
> code to display ratings on the same page as licenses. or is this just
> a bad idea?


Lift snippets are evaluated lazily.  What this means is that you'll get

<h3><l:type /></h3>

       <table>
                       <lift:Ratings.index>
                       <tr>
             <td><r:rating /></td>
                       </tr>
                       </lift:Ratings.index>
       </table>

Passed to the Licenses.index snippet.  Your snippet may choose to return the
xhtml bound or it may choose to evaluate the inner part as well:

object CurrentLicense extends
scala.util.DynamicVariable[Box[License]](Empty)

class Licenses {
  def index(xhmtl: NodeSeq): NodeSeq = {
   val currentLicense = calcLicense
   for {
     session <- S.session.toList
     val bound = bind("l", xhtml, "type" -> currentLicense.theType)
     node <-
CurrentLicense.withValue(Full(currentLicense)){session.processSurroundAndInclude(PageName
get, bound)}
   } yield node
  }
}

In the Ratings snippet, you just have to get the current license from the
CurrentLicense DynamicVariable.


>
> >
>


-- 
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Git some: http://github.com/dpp

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

Reply via email to