Is there away to force eager evaluation of a snippet body?

128 views
Skip to first unread message

Jeppe Nejsum Madsen

unread,
Mar 10, 2011, 10:44:22 AM3/10/11
to lif...@googlegroups.com
Hi

I have some markup that I would like to put in a separate file, but I
can't seem to get this to work with CSS transformations without using
eager_eval=true on the surrounding snippet

This is the template:

<lift:MySnippet eager_eval=true">
<div id="post">
<lift:embed what="/fragments/import_results"></lift:embed>
....
</div>
<div id="get">...</div>
...
</lift:MySnippet>

The embedded fragment:
<div>
Result: <span class="result">the result</span>
Filename: <span class="file_name">the filename</span>
</div>

Snippet:

"#post ^*" #> "dummy" &
".result" #> "foo" &
".file_name" #> "bar"

Right now,

1) I have to remember to add eager_eval to every use of MySnippet and
2) It evaluates more than is necessary since I always select part of
the snippet body.

It would be nice to only eagerly evaluate contents of the #post div.
Is this possible? Is it a useful feature?

/Jeppe

David Pollak

unread,
Mar 10, 2011, 12:28:34 PM3/10/11
to lif...@googlegroups.com
On Thu, Mar 10, 2011 at 7:44 AM, Jeppe Nejsum Madsen <je...@ingolfs.dk> wrote:
Hi

I have some markup that I would like to put in a separate file, but I
can't seem to get this to work with CSS transformations without using
eager_eval=true on the surrounding snippet

This is the template:

<lift:MySnippet eager_eval=true">
  <div id="post">
     <lift:embed what="/fragments/import_results"></lift:embed>
     ....
  </div>
 <div id="get">...</div>
 ...
</lift:MySnippet>

The embedded fragment:
<div>
 Result: <span class="result">the result</span>
 Filename: <span class="file_name">the filename</span>
</div>

Snippet:

         "#post ^*" #> "dummy" &
           ".result" #> "foo" &
           ".file_name" #> "bar"


I just pushed code that will let you do:

"#post" #> (S.eagerEval andThen ".result" #> "foo" & ".file_name" #> "bar")
 
Right now,

1) I have to remember to add eager_eval to every use of MySnippet and
2) It evaluates more than is necessary since I always select part of
the snippet body.

It would be nice to only eagerly evaluate contents of the #post div.
Is this possible? Is it a useful feature?

/Jeppe

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




--
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Blog: http://goodstuff.im
Surf the harmonics

Jeppe Nejsum Madsen

unread,
Mar 10, 2011, 4:00:18 PM3/10/11
to lif...@googlegroups.com

You seem to be pushing a lot for me lately, thanks :-)

/Jeppe

David Pollak

unread,
Mar 10, 2011, 4:32:45 PM3/10/11
to lif...@googlegroups.com
That's 'cause you keep pushing Lift in a good direction.  Thanks for your efforts and help!
 

/Jeppe

>
>>
>> Right now,
>>
>> 1) I have to remember to add eager_eval to every use of MySnippet and
>> 2) It evaluates more than is necessary since I always select part of
>> the snippet body.
>>
>> It would be nice to only eagerly evaluate contents of the #post div.
>> Is this possible? Is it a useful feature?

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

Jeppe Nejsum Madsen

unread,
Mar 11, 2011, 8:49:48 AM3/11/11
to lif...@googlegroups.com
On Thu, Mar 10, 2011 at 6:28 PM, David Pollak
<feeder.of...@gmail.com> wrote:
>
>

Just tried this and I can't seem to make it work with the "^*" selector

I haven't fully grokked the wizardry behind the Css selectors, but

"#post ^*" #> "dummy" & (S.eagerEval andThen ".result" #> "foo" &
".file_name" #> "bar")

doesn't work since eagerEval is a NodeSeq=>NodeSeq and not a CssSel

/Jeppe

David Pollak

unread,
Mar 11, 2011, 8:56:51 AM3/11/11
to lif...@googlegroups.com
"#post ^*" #> "dummy" andThen (S.eagerEval andThen ".result" #> "foo" & ".file_name" #> "bar")
 

/Jeppe

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




--
Lift, the simply functional web framework http://liftweb.net

Jeppe Nejsum Madsen

unread,
Mar 11, 2011, 9:38:05 AM3/11/11
to lif...@googlegroups.com
On Fri, Mar 11, 2011 at 2:56 PM, David Pollak

Thanks again. I actually tried that but had my snippet return a
CssBindFunc (to catch any problems with conversions). The above turns
the result into a NodeSeq=>NodeSeq (which of course is fine for a
snippet). A little tricky to figure out when & where the implicit
conversions kick in....

/Jeppe

Reply all
Reply to author
Forward
0 new messages