[Lift] Re: bind with outer element?

2009-08-12 Thread David Pollak
On Wed, Aug 12, 2009 at 11:31 AM, jon  wrote:

>
> Thanks Ross! that works.


+1


>
>
> On Aug 12, 1:59 pm, Ross Mellgren  wrote:
> > BindHelpers.currentNode is a Box[NodeSeq] that gives you the node that
> > bind is currently replacing.
> >
> > -Ross
> >
> > On Aug 12, 2009, at 11:02 AM, jon wrote:
> >
> >
> >
> >
> >
> > > Hi,
> >
> > > I actually solved by wrapping the node i cared about in another node,
> > > but tried the FuncBindParam and it does seem to only grab the child
> > > nodes.
> >
> > > On Aug 11, 11:37 pm, Naftoli Gugenheim  wrote:
> > >> Doesn't the FuncBindParam only get the element's child NodeSeq?
> >
> > >> -
> >
> > >> David Pollak wrote:
> > >> On Mon, Aug 10, 2009 at 1:44 PM, jon  wrote:
> >
> > >>> Hi,
> >
> > >>> I have a template with the following
> >
> > >>> 
> > >>>  
> > >>>  
> > >>>
> > >>>...
> > >>>  
> > >>> 
> >
> > >>> And a snippet like:
> >
> > >>> def doSnippet(x:NodeSeq):NodeSeq = {
> > >>>  bind("t", x,
> > >>>"name"-> (doName(_)),
> >
> > >> try:
> >
> > >> def myFunc(node: NodeSeq): NodeSeq = if ((node \ "@shorten").isEmpty)
> > >> longVersion else shortVersion
> >
> > >> bind("t", x, FuncBindParam("name", myFunc _))
> >
> > >> You get the complete  passed to myFunc.
> >
> > >> Thanks,
> >
> > >> David
> >
> > >>>"foo" -> (doForm(_))
> > >>>  )
> > >>> }
> >
> > >>> In the code above only the contents of the bound tags are available
> > >>> for doName and doForm, if I want to be able to read the attribute
> > >>> "shorten" in doName and have "foo" render with an enclosing 
> > >>> tag,  how do I create the bind params?
> >
> > >>> I am doing an expensive batch operation upfront, so I want
> > >>> everything
> > >>> to be in the same snippet.
> >
> > >>> Thanks,
> >
> > >>> Jon
> >
> > >> --
> > >> Lift, the simply functional web frameworkhttp://liftweb.net
> > >> Beginning Scalahttp://www.apress.com/book/view/1430219890
> > >> Follow me:http://twitter.com/dpp
> > >> Git some:http://github.com/dpp
> >
>


-- 
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 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
-~--~~~~--~~--~--~---



[Lift] Re: bind with outer element?

2009-08-12 Thread jon

Thanks Ross! that works.

On Aug 12, 1:59 pm, Ross Mellgren  wrote:
> BindHelpers.currentNode is a Box[NodeSeq] that gives you the node that  
> bind is currently replacing.
>
> -Ross
>
> On Aug 12, 2009, at 11:02 AM, jon wrote:
>
>
>
>
>
> > Hi,
>
> > I actually solved by wrapping the node i cared about in another node,
> > but tried the FuncBindParam and it does seem to only grab the child
> > nodes.
>
> > On Aug 11, 11:37 pm, Naftoli Gugenheim  wrote:
> >> Doesn't the FuncBindParam only get the element's child NodeSeq?
>
> >> -
>
> >> David Pollak wrote:
> >> On Mon, Aug 10, 2009 at 1:44 PM, jon  wrote:
>
> >>> Hi,
>
> >>> I have a template with the following
>
> >>> 
> >>>  
> >>>  
> >>>    
> >>>    ...
> >>>  
> >>> 
>
> >>> And a snippet like:
>
> >>> def doSnippet(x:NodeSeq):NodeSeq = {
> >>>  bind("t", x,
> >>>    "name"-> (doName(_)),
>
> >> try:
>
> >> def myFunc(node: NodeSeq): NodeSeq = if ((node \ "@shorten").isEmpty)
> >> longVersion else shortVersion
>
> >> bind("t", x, FuncBindParam("name", myFunc _))
>
> >> You get the complete  passed to myFunc.
>
> >> Thanks,
>
> >> David
>
> >>>    "foo" -> (doForm(_))
> >>>  )
> >>> }
>
> >>> In the code above only the contents of the bound tags are available
> >>> for doName and doForm, if I want to be able to read the attribute
> >>> "shorten" in doName and have "foo" render with an enclosing 
> >>> tag,  how do I create the bind params?
>
> >>> I am doing an expensive batch operation upfront, so I want  
> >>> everything
> >>> to be in the same snippet.
>
> >>> Thanks,
>
> >>> Jon
>
> >> --
> >> Lift, the simply functional web frameworkhttp://liftweb.net
> >> Beginning Scalahttp://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 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
-~--~~~~--~~--~--~---



[Lift] Re: bind with outer element?

2009-08-12 Thread Ross Mellgren

BindHelpers.currentNode is a Box[NodeSeq] that gives you the node that  
bind is currently replacing.

-Ross

On Aug 12, 2009, at 11:02 AM, jon wrote:

>
> Hi,
>
> I actually solved by wrapping the node i cared about in another node,
> but tried the FuncBindParam and it does seem to only grab the child
> nodes.
>
> On Aug 11, 11:37 pm, Naftoli Gugenheim  wrote:
>> Doesn't the FuncBindParam only get the element's child NodeSeq?
>>
>> -
>>
>>
>>
>>
>>
>> David Pollak wrote:
>> On Mon, Aug 10, 2009 at 1:44 PM, jon  wrote:
>>
>>> Hi,
>>
>>> I have a template with the following
>>
>>> 
>>>  
>>>  
>>>
>>>...
>>>  
>>> 
>>
>>> And a snippet like:
>>
>>> def doSnippet(x:NodeSeq):NodeSeq = {
>>>  bind("t", x,
>>>"name"-> (doName(_)),
>>
>> try:
>>
>> def myFunc(node: NodeSeq): NodeSeq = if ((node \ "@shorten").isEmpty)
>> longVersion else shortVersion
>>
>> bind("t", x, FuncBindParam("name", myFunc _))
>>
>> You get the complete  passed to myFunc.
>>
>> Thanks,
>>
>> David
>>
>>
>>
>>
>>
>>>"foo" -> (doForm(_))
>>>  )
>>> }
>>
>>> In the code above only the contents of the bound tags are available
>>> for doName and doForm, if I want to be able to read the attribute
>>> "shorten" in doName and have "foo" render with an enclosing 
>>> tag,  how do I create the bind params?
>>
>>> I am doing an expensive batch operation upfront, so I want  
>>> everything
>>> to be in the same snippet.
>>
>>> Thanks,
>>
>>> Jon
>>
>> --
>> Lift, the simply functional web frameworkhttp://liftweb.net
>> Beginning Scalahttp://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 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
-~--~~~~--~~--~--~---



[Lift] Re: bind with outer element?

2009-08-12 Thread jon

Hi,

I actually solved by wrapping the node i cared about in another node,
but tried the FuncBindParam and it does seem to only grab the child
nodes.

On Aug 11, 11:37 pm, Naftoli Gugenheim  wrote:
> Doesn't the FuncBindParam only get the element's child NodeSeq?
>
> -
>
>
>
>
>
> David Pollak wrote:
> On Mon, Aug 10, 2009 at 1:44 PM, jon  wrote:
>
> > Hi,
>
> > I have a template with the following
>
> > 
> >  
> >  
> >    
> >    ...
> >  
> > 
>
> > And a snippet like:
>
> > def doSnippet(x:NodeSeq):NodeSeq = {
> >  bind("t", x,
> >    "name"-> (doName(_)),
>
> try:
>
> def myFunc(node: NodeSeq): NodeSeq = if ((node \ "@shorten").isEmpty)
> longVersion else shortVersion
>
> bind("t", x, FuncBindParam("name", myFunc _))
>
> You get the complete  passed to myFunc.
>
> Thanks,
>
> David
>
>
>
>
>
> >    "foo" -> (doForm(_))
> >  )
> > }
>
> > In the code above only the contents of the bound tags are available
> > for doName and doForm, if I want to be able to read the attribute
> > "shorten" in doName and have "foo" render with an enclosing 
> > tag,  how do I create the bind params?
>
> > I am doing an expensive batch operation upfront, so I want everything
> > to be in the same snippet.
>
> > Thanks,
>
> > Jon
>
> --
> Lift, the simply functional web frameworkhttp://liftweb.net
> Beginning Scalahttp://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 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
-~--~~~~--~~--~--~---



[Lift] Re: bind with outer element?

2009-08-11 Thread Naftoli Gugenheim

Doesn't the FuncBindParam only get the element's child NodeSeq?

-
David Pollak wrote:

On Mon, Aug 10, 2009 at 1:44 PM, jon  wrote:

>
> Hi,
>
> I have a template with the following
>
> 
>  
>  
>
>...
>  
> 
>
> And a snippet like:
>
> def doSnippet(x:NodeSeq):NodeSeq = {
>  bind("t", x,
>"name"-> (doName(_)),


try:

def myFunc(node: NodeSeq): NodeSeq = if ((node \ "@shorten").isEmpty)
longVersion else shortVersion

bind("t", x, FuncBindParam("name", myFunc _))

You get the complete  passed to myFunc.

Thanks,

David


>"foo" -> (doForm(_))
>  )
> }
>
> In the code above only the contents of the bound tags are available
> for doName and doForm, if I want to be able to read the attribute
> "shorten" in doName and have "foo" render with an enclosing 
> tag,  how do I create the bind params?
>
> I am doing an expensive batch operation upfront, so I want everything
> to be in the same snippet.
>
> Thanks,
>
> Jon
>
> >
>


-- 
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 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
-~--~~~~--~~--~--~---



[Lift] Re: bind with outer element?

2009-08-11 Thread David Pollak
On Mon, Aug 10, 2009 at 1:44 PM, jon  wrote:

>
> Hi,
>
> I have a template with the following
>
> 
>  
>  
>
>...
>  
> 
>
> And a snippet like:
>
> def doSnippet(x:NodeSeq):NodeSeq = {
>  bind("t", x,
>"name"-> (doName(_)),


try:

def myFunc(node: NodeSeq): NodeSeq = if ((node \ "@shorten").isEmpty)
longVersion else shortVersion

bind("t", x, FuncBindParam("name", myFunc _))

You get the complete  passed to myFunc.

Thanks,

David


>"foo" -> (doForm(_))
>  )
> }
>
> In the code above only the contents of the bound tags are available
> for doName and doForm, if I want to be able to read the attribute
> "shorten" in doName and have "foo" render with an enclosing 
> tag,  how do I create the bind params?
>
> I am doing an expensive batch operation upfront, so I want everything
> to be in the same snippet.
>
> Thanks,
>
> Jon
>
> >
>


-- 
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 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
-~--~~~~--~~--~--~---



[Lift] Re: bind with outer element?

2009-08-11 Thread Naftoli Gugenheim

If I'm not mistaken, S.attr is an attribute on the snippet xml node; for the 
node currently being processed by bind you use BindHelpers.attr

-
Timothy Perrett wrote:


Jon,

To read attributes, you do the following:

S.attr("shorten") // => Box[String]

Cheers, Tim


On Aug 10, 9:44 pm, jon  wrote:
> Hi,
>
> I have a template with the following
>
> 
>   
>   
>     
>     ...
>   
> 
>
> And a snippet like:
>
> def doSnippet(x:NodeSeq):NodeSeq = {
>   bind("t", x,
>     "name"-> (doName(_)),
>     "foo" -> (doForm(_))
>   )
>
> }
>
> In the code above only the contents of the bound tags are available
> for doName and doForm, if I want to be able to read the attribute
> "shorten" in doName and have "foo" render with an enclosing 
> tag,  how do I create the bind params?
>
> I am doing an expensive batch operation upfront, so I want everything
> to be in the same snippet.
>
> Thanks,
>
> Jon


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[Lift] Re: bind with outer element?

2009-08-11 Thread Timothy Perrett

Jon,

To read attributes, you do the following:

S.attr("shorten") // => Box[String]

Cheers, Tim


On Aug 10, 9:44 pm, jon  wrote:
> Hi,
>
> I have a template with the following
>
> 
>   
>   
>     
>     ...
>   
> 
>
> And a snippet like:
>
> def doSnippet(x:NodeSeq):NodeSeq = {
>   bind("t", x,
>     "name"-> (doName(_)),
>     "foo" -> (doForm(_))
>   )
>
> }
>
> In the code above only the contents of the bound tags are available
> for doName and doForm, if I want to be able to read the attribute
> "shorten" in doName and have "foo" render with an enclosing 
> tag,  how do I create the bind params?
>
> I am doing an expensive batch operation upfront, so I want everything
> to be in the same snippet.
>
> Thanks,
>
> Jon
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---