[Lift] Re: How does lift wrap the templates

2008-12-06 Thread Tim Perrett

Hey David,

I see you unified TemplatePf and ViewDispatchPf - in lift of this re-
factoring, how does that now change what i need to do here?

Cheers

Tim
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: How does lift wrap the templates

2008-12-06 Thread Tim Perrett

David,

Thanks for your previous example - I tried the following code:

object ExampleLoader {
  def template: LiftRules.ViewDispatchPF = {
case badger :: Nil = Full(demo)
  }

  def demo: NodeSeq = html/html

}

And then i get this error:

[INFO]  found   : net.liftweb.util.Full[scala.xml.NodeSeq]
[INFO]  required: Either[() = net.liftweb.util.Can
[scala.xml.NodeSeq],net.liftweb.http.LiftView]
[INFO] case badger :: Nil = Full(demo)

Whats all this Either[] business about?

Cheers

Tim


 Tim,

 I've already written example code for ViewDispatchPF.  Please look at the
 code I've supplied.

 Once you've got some code that's kinda-sorta working, I'll be glad to help
 you address issues or debug.

 Thanks,

 David

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: How does lift wrap the templates

2008-12-06 Thread Jorge Ortiz
Try:

  case badger :: Nil = Left(() = demo)

An Either[A, B] means it can be either a Left[A] or a Right[B].

--j

On Sat, Dec 6, 2008 at 12:35 PM, Tim Perrett [EMAIL PROTECTED] wrote:


 Sorry, the code should have been:

 object ExampleLoader {
  def template: LiftRules.ViewDispatchPF = {
 case badger :: Nil = () = demo
  }

  def demo: Can[NodeSeq] = Full(html/html)

 }


 [INFO]  found   : () = net.liftweb.util.Can[scala.xml.NodeSeq]
 [INFO]  required: Either[() = net.liftweb.util.Can
 [scala.xml.NodeSeq],net.liftweb.http.LiftView]
 [INFO] case badger :: Nil = () = demo
 [INFO]^



 Cheers, Tim
 


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: How does lift wrap the templates

2008-12-06 Thread Tim Perrett

A - thats some scala Voodoo - never seen the Either construct
before!

Thanks Jorge

On Dec 6, 6:39 pm, Jorge Ortiz [EMAIL PROTECTED] wrote:
 Try:

   case badger :: Nil = Left(() = demo)

 An Either[A, B] means it can be either a Left[A] or a Right[B].

 --j

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: How does lift wrap the templates

2008-12-05 Thread Tim Perrett

Hey guys,

Some of this is a bit above my head unfortunately as im not familiar
with lift's templating system. Let me try and clarify what i've been
playing with so far:

object DatabaseTemplateLoader {
  def template: LiftRules.TemplatePF = {
case Req(page, , _) = () = DatabaseTemplateLoader(page)
  }
  def apply(path: List[String]): Can[NodeSeq] = {
val pages = Model.createNamedQuery[Content]
(content.get.path.full,page - path.last).findAll.toList
if(pages.map(p = p.name) == path){
  PCDataXmlParser(new ByteArrayInputStream
(pages.last.body.toString.getBytes(UTF-8)))
} else {
  Full(spanNO FILE SPECIFIED/span)
}
  }
}

This works no problem, and drops in as a replacement for reading them
off the filesystem. If my database template content has something
like:

lift:surround with=default at=content
h1My Content/h1
/lift:surround

Then the layout is rendered. However, what i want to do is grab the
layout the user chose to use with that page and automatically use that
(the value will is stored in the database) - this is where im getting
confused.

What would you guys suggest?

Cheers

Tim





--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: How does lift wrap the templates

2008-12-05 Thread David Pollak
On Fri, Dec 5, 2008 at 7:35 AM, Tim Perrett [EMAIL PROTECTED] wrote:


  I'd suggest creating a ViewDispatchPF and adding it in using
  LiftRules.appendViewDispatch
 
  type ViewDispatchPF = PartialFunction[List[String], LiftView]
 
  So, it's going to look a lot like your existing code.

 Excuse my ignorance, but what's the difference between TemplatePF and
 ViewDispatchPF?


type TemplatePF = PartialFunction[Req,() = Can[NodeSeq]]

  type ViewDispatchPF = PartialFunction[List[String], LiftView]

As per my exchange with Marius, the TemplatePF is used to map the Req(uest)
to the NodeSeq that represents the page that satisfies the Req(uest).

However, the initial XHTML may reference other XHTML.  Typically, these
XHTML chunks are templates such as the surround template or perhaps a search
template.  Lift references these XHTML chunks by path, not Req.  Thus, there
must be a way to translate between a path and something to vend the XHTML
chunks.  The ViewDispatch mechanism does this translation.  If there is no
ViewDispatch that can satisfy the path, then Lift looks in the filesystem.

So, what does the LiftView trait look like:
/**
 *  The preferred way to do lift views... implement a partial function that
dispatches
 * the incoming request to an appropriate method
 */
trait LiftView {
  implicit def nsToCns(in: NodeSeq): Can[NodeSeq] = Can.legacyNullTest(in)
  def dispatch : PartialFunction[String, () = Can[NodeSeq]]
}

So, your code would look something like:

LiftRules.appendViewDispatch {
  case templates-hidden :: Nil = new LiftView {
def dispatch  = {
  case default = loadDefaultTemplateFromDB _
}

def loadDefaultTemplateFromDB(): Can[NodeSeq] = 
  }
}

There is no documentation on what ViewDispatch is
 actually for - my understanding of views within lift, were
 dynamically generated stuff like XML RSS feeds or such. Is this not
 the case?


No.  A view is XHTML used to render a page to the browser.  XML and RSS
feeds are handled using an entirely different mechanism.




 Im confused as to what this has to do with my use case?

 Cheers

 Tim

 PS: sorry if this appears like im being very slow!
 



-- 
Lift, the simply functional web framework http://liftweb.net
Collaborative Task Management http://much4.us
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: How does lift wrap the templates

2008-12-05 Thread David Pollak
On Fri, Dec 5, 2008 at 9:56 AM, Marius [EMAIL PROTECTED] wrote:


 David,

 I understand the rationale for the existence of these 2 things ... but
 apparently it creates some sort of confusion. I wonder if there is a
 way of unifying them. I'm thinking that there might be cases where
 in order to load views from some endpoint one would have to implement
 a TemplatePf and a ViewDispatchPf ... which is some extent may seem
 redundant.

 Would it make any sense to have ?

 type TemplatePf = PartialFunction[(List[String], Req),() = Can
 [NodeSeq]]


No.  There are a bunch of problems with this:

   - The Req is not always around, so you'd have to have have to have
   Can[Req] and then the whole pattern matching thing becomes ugly and unweildy
   - Even without the Can[Req], there's a lot of cruft in the pattern
   - The goals are slightly different.  TemplatePF returns a Can[NodeSeq],
   where ViewDispatchPF returns a LiftView.  LiftView is used elsewhere.

If anything, I'd opt for getting rid of TemplatePF all-together.  But, last
time I tried that, there were a bunch of things that stopped working.  I may
be able to overcome those issues with some recent additions to Loc.




 and even if we are in the middle of processing chunks of templates the
 path is provided as well as the initial Req and pattern matching can
 still be done. At the first call the List[String] is probably the same
 with Req.parsePath.path but I don;t see it as a major inconvenience.


Actually, the Req is not passed around, so it's not always available.





 Br's,
 Marius

 On Dec 5, 6:33 pm, David Pollak [EMAIL PROTECTED]
 wrote:
  On Fri, Dec 5, 2008 at 7:35 AM, Tim Perrett [EMAIL PROTECTED]
 wrote:
 
I'd suggest creating a ViewDispatchPF and adding it in using
LiftRules.appendViewDispatch
 
type ViewDispatchPF = PartialFunction[List[String], LiftView]
 
So, it's going to look a lot like your existing code.
 
   Excuse my ignorance, but what's the difference between TemplatePF and
   ViewDispatchPF?
 
  type TemplatePF = PartialFunction[Req,() = Can[NodeSeq]]
 
type ViewDispatchPF = PartialFunction[List[String], LiftView]
 
  As per my exchange with Marius, the TemplatePF is used to map the
 Req(uest)
  to the NodeSeq that represents the page that satisfies the Req(uest).
 
  However, the initial XHTML may reference other XHTML.  Typically, these
  XHTML chunks are templates such as the surround template or perhaps a
 search
  template.  Lift references these XHTML chunks by path, not Req.  Thus,
 there
  must be a way to translate between a path and something to vend the XHTML
  chunks.  The ViewDispatch mechanism does this translation.  If there is
 no
  ViewDispatch that can satisfy the path, then Lift looks in the
 filesystem.
 
  So, what does the LiftView trait look like:
  /**
   *  The preferred way to do lift views... implement a partial function
 that
  dispatches
   * the incoming request to an appropriate method
   */
  trait LiftView {
implicit def nsToCns(in: NodeSeq): Can[NodeSeq] =
 Can.legacyNullTest(in)
def dispatch : PartialFunction[String, () = Can[NodeSeq]]
 
  }
 
  So, your code would look something like:
 
  LiftRules.appendViewDispatch {
case templates-hidden :: Nil = new LiftView {
  def dispatch  = {
case default = loadDefaultTemplateFromDB _
  }
 
  def loadDefaultTemplateFromDB(): Can[NodeSeq] = 
}
 
  }
 
  There is no documentation on what ViewDispatch is
 
   actually for - my understanding of views within lift, were
   dynamically generated stuff like XML RSS feeds or such. Is this not
   the case?
 
  No.  A view is XHTML used to render a page to the browser.  XML and RSS
  feeds are handled using an entirely different mechanism.
 
 
 
   Im confused as to what this has to do with my use case?
 
   Cheers
 
   Tim
 
   PS: sorry if this appears like im being very slow!
 
  --
  Lift, the simply functional web frameworkhttp://liftweb.net
  Collaborative Task Managementhttp://much4.us
  Follow me:http://twitter.com/dpp
  Git some:http://github.com/dpp
 



-- 
Lift, the simply functional web framework http://liftweb.net
Collaborative Task Management http://much4.us
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: How does lift wrap the templates

2008-12-04 Thread Derek Chen-Becker
Are you talking about lift:surround/ tags? Those are handled in
LiftSession.processSurroundAndInclude, line 697. Here's some example code
for a utility method from an old app that uses it in some DispatchPFs I was
running:

  def process (xhtml : NodeSeq) : XmlResponse = {
val data = lift:surround with=default
at=content{xhtml}/lift:surround
XmlResponse(html{
S.session.open_!.processSurroundAndInclude(S.uri,data)}/html)
  }


Derek

On Thu, Dec 4, 2008 at 12:50 PM, Tim Perrett [EMAIL PROTECTED] wrote:


 Hey guys,

 Within lift, I cant seem to find where the content returned from
 whatever template mech then gets bound to the layout content?

 Can someone point me in the right direction?

 Cheers

 Tim
 


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: How does lift wrap the templates

2008-12-04 Thread Marius

Unless I'm missing something LiftRules.addTemplateBefore should
suffice. Lift (see findVisibleTemplate which is called before
processSurroundAndInclude) will look for your template so your Pf can
return it virtually from anywhere.

Br's,
Marius

On Dec 4, 10:10 pm, Derek Chen-Becker [EMAIL PROTECTED] wrote:
 Ahh. What would make this really simple is if LiftRules.finder was a PF
 instead of a straight def, since LiftRules.finder is what actually tries to
 locate the template using ClassLoader.getResourceAsStream currently. In the
 meantime, you might have luck with LiftRules.liftTagProcessing. You can
 define your own PF that handles surround specially. In particular, I'd look
 at processSurroundElement (and the related findAndMerge and processBind) in
 LiftSession.scala.

 Derek

 On Thu, Dec 4, 2008 at 1:27 PM, Tim Perrett [EMAIL PROTECTED] wrote:

  I am indeed talking about lift:surround :)

  I see processSurroundAndInclude and what it does, but what i really
  want to do it set the content of the surround dynamically (from a
  layout i'll store in the DB)

  How would one go about doing this?

  Cheers

  Tim

  On Dec 4, 7:01 pm, Derek Chen-Becker [EMAIL PROTECTED] wrote:
   Are you talking about lift:surround/ tags? Those are handled in
   LiftSession.processSurroundAndInclude, line 697. Here's some example code
   for a utility method from an old app that uses it in some DispatchPFs I
  was
   running:

     def process (xhtml : NodeSeq) : XmlResponse = {
       val data = lift:surround with=default
   at=content{xhtml}/lift:surround
       XmlResponse(html{
   S.session.open_!.processSurroundAndInclude(S.uri,data)}/html)
     }

   Derek

   On Thu, Dec 4, 2008 at 12:50 PM, Tim Perrett [EMAIL PROTECTED]
  wrote:

Hey guys,

Within lift, I cant seem to find where the content returned from
whatever template mech then gets bound to the layout content?

Can someone point me in the right direction?

Cheers

Tim
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: How does lift wrap the templates

2008-12-04 Thread David Pollak
On Thu, Dec 4, 2008 at 12:24 PM, Marius [EMAIL PROTECTED] wrote:


 Unless I'm missing something LiftRules.addTemplateBefore should
 suffice. Lift (see findVisibleTemplate which is called before
 processSurroundAndInclude) will look for your template so your Pf can
 return it virtually from anywhere.


However, findVisibleTemplate is not called by the mechanism that looks up
the surround template. :-(




 Br's,
 Marius

 On Dec 4, 10:10 pm, Derek Chen-Becker [EMAIL PROTECTED] wrote:
  Ahh. What would make this really simple is if LiftRules.finder was a PF
  instead of a straight def, since LiftRules.finder is what actually tries
 to
  locate the template using ClassLoader.getResourceAsStream currently. In
 the
  meantime, you might have luck with LiftRules.liftTagProcessing. You can
  define your own PF that handles surround specially. In particular, I'd
 look
  at processSurroundElement (and the related findAndMerge and processBind)
 in
  LiftSession.scala.
 
  Derek
 
  On Thu, Dec 4, 2008 at 1:27 PM, Tim Perrett [EMAIL PROTECTED]
 wrote:
 
   I am indeed talking about lift:surround :)
 
   I see processSurroundAndInclude and what it does, but what i really
   want to do it set the content of the surround dynamically (from a
   layout i'll store in the DB)
 
   How would one go about doing this?
 
   Cheers
 
   Tim
 
   On Dec 4, 7:01 pm, Derek Chen-Becker [EMAIL PROTECTED] wrote:
Are you talking about lift:surround/ tags? Those are handled in
LiftSession.processSurroundAndInclude, line 697. Here's some example
 code
for a utility method from an old app that uses it in some DispatchPFs
 I
   was
running:
 
  def process (xhtml : NodeSeq) : XmlResponse = {
val data = lift:surround with=default
at=content{xhtml}/lift:surround
XmlResponse(html{
S.session.open_!.processSurroundAndInclude(S.uri,data)}/html)
  }
 
Derek
 
On Thu, Dec 4, 2008 at 12:50 PM, Tim Perrett [EMAIL PROTECTED]
   wrote:
 
 Hey guys,
 
 Within lift, I cant seem to find where the content returned from
 whatever template mech then gets bound to the layout content?
 
 Can someone point me in the right direction?
 
 Cheers
 
 Tim
 



-- 
Lift, the simply functional web framework http://liftweb.net
Collaborative Task Management http://much4.us
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: How does lift wrap the templates

2008-12-04 Thread Derek Chen-Becker
Cool, I missed the viewDispatch call in findAnyTemplate. As always, you're
one step ahead :)

Derek

On Thu, Dec 4, 2008 at 2:28 PM, David Pollak
[EMAIL PROTECTED]wrote:



 On Thu, Dec 4, 2008 at 11:27 AM, Tim Perrett [EMAIL PROTECTED] wrote:


 I am indeed talking about lift:surround :)

 I see processSurroundAndInclude and what it does, but what i really
 want to do it set the content of the surround dynamically (from a
 layout i'll store in the DB)

 How would one go about doing this?


 All Lift views are looked up via the LiftRule.viewDispatch.  You can put a
 partial function via LiftRules.appendViewDispatch to match your template.
 Lift will expect a LiftView which is a trait that can do the RDBMS lookup.




 Cheers

 Tim



 On Dec 4, 7:01 pm, Derek Chen-Becker [EMAIL PROTECTED] wrote:
  Are you talking about lift:surround/ tags? Those are handled in
  LiftSession.processSurroundAndInclude, line 697. Here's some example
 code
  for a utility method from an old app that uses it in some DispatchPFs I
 was
  running:
 
def process (xhtml : NodeSeq) : XmlResponse = {
  val data = lift:surround with=default
  at=content{xhtml}/lift:surround
  XmlResponse(html{
  S.session.open_!.processSurroundAndInclude(S.uri,data)}/html)
}
 
  Derek
 
  On Thu, Dec 4, 2008 at 12:50 PM, Tim Perrett [EMAIL PROTECTED]
 wrote:
 
   Hey guys,
 
   Within lift, I cant seem to find where the content returned from
   whatever template mech then gets bound to the layout content?
 
   Can someone point me in the right direction?
 
   Cheers
 
   Tim




 --
 Lift, the simply functional web framework http://liftweb.net
 Collaborative Task Management http://much4.us
 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: How does lift wrap the templates

2008-12-04 Thread Marius



On Dec 4, 10:29 pm, David Pollak [EMAIL PROTECTED]
wrote:
 On Thu, Dec 4, 2008 at 12:24 PM, Marius [EMAIL PROTECTED] wrote:

  Unless I'm missing something LiftRules.addTemplateBefore should
  suffice. Lift (see findVisibleTemplate which is called before
  processSurroundAndInclude) will look for your template so your Pf can
  return it virtually from anywhere.

 However, findVisibleTemplate is not called by the mechanism that looks up
 the surround template. :-(

Any particular reason not to? ... seems like it is at least as
appropriate as LiftRules.viewDispatch.It would boil down to
findAnyTemplate logic isn't it? .. but then again is there some sort
of redundancy between templates Pf and viewDispatch ? .. which would
have higher precedence?






  Br's,
  Marius

  On Dec 4, 10:10 pm, Derek Chen-Becker [EMAIL PROTECTED] wrote:
   Ahh. What would make this really simple is if LiftRules.finder was a PF
   instead of a straight def, since LiftRules.finder is what actually tries
  to
   locate the template using ClassLoader.getResourceAsStream currently. In
  the
   meantime, you might have luck with LiftRules.liftTagProcessing. You can
   define your own PF that handles surround specially. In particular, I'd
  look
   at processSurroundElement (and the related findAndMerge and processBind)
  in
   LiftSession.scala.

   Derek

   On Thu, Dec 4, 2008 at 1:27 PM, Tim Perrett [EMAIL PROTECTED]
  wrote:

I am indeed talking about lift:surround :)

I see processSurroundAndInclude and what it does, but what i really
want to do it set the content of the surround dynamically (from a
layout i'll store in the DB)

How would one go about doing this?

Cheers

Tim

On Dec 4, 7:01 pm, Derek Chen-Becker [EMAIL PROTECTED] wrote:
 Are you talking about lift:surround/ tags? Those are handled in
 LiftSession.processSurroundAndInclude, line 697. Here's some example
  code
 for a utility method from an old app that uses it in some DispatchPFs
  I
was
 running:

   def process (xhtml : NodeSeq) : XmlResponse = {
     val data = lift:surround with=default
 at=content{xhtml}/lift:surround
     XmlResponse(html{
 S.session.open_!.processSurroundAndInclude(S.uri,data)}/html)
   }

 Derek

 On Thu, Dec 4, 2008 at 12:50 PM, Tim Perrett [EMAIL PROTECTED]
wrote:

  Hey guys,

  Within lift, I cant seem to find where the content returned from
  whatever template mech then gets bound to the layout content?

  Can someone point me in the right direction?

  Cheers

  Tim

 --
 Lift, the simply functional web frameworkhttp://liftweb.net
 Collaborative Task Managementhttp://much4.us
 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: How does lift wrap the templates

2008-12-04 Thread David Pollak
On Thu, Dec 4, 2008 at 12:38 PM, Marius [EMAIL PROTECTED] wrote:




 On Dec 4, 10:29 pm, David Pollak [EMAIL PROTECTED]
 wrote:
  On Thu, Dec 4, 2008 at 12:24 PM, Marius [EMAIL PROTECTED] wrote:
 
   Unless I'm missing something LiftRules.addTemplateBefore should
   suffice. Lift (see findVisibleTemplate which is called before
   processSurroundAndInclude) will look for your template so your Pf can
   return it virtually from anywhere.
 
  However, findVisibleTemplate is not called by the mechanism that looks up
  the surround template. :-(

 Any particular reason not to? ... seems like it is at least as
 appropriate as LiftRules.viewDispatch.It would boil down to
 findAnyTemplate logic isn't it? .. but then again is there some sort
 of redundancy between templates Pf and viewDispatch ? .. which would
 have higher precedence?


The issue is that TemplatePF does its lookup based on a Req... the request.
This makes sense because you may want to look things up based on an incoming
request including the path, the postfix, etc.  On the other hand,
findTemplate is called with a path... a List[String] because it's no longer
part of the Req, but being called by something beyond the Req.  I tried to
unify the two constructs about a month ago and found use cases in my code
for both constructs... thus they are both in Lift and serve their own
purpose.




 
 
 
 
 
   Br's,
   Marius
 
   On Dec 4, 10:10 pm, Derek Chen-Becker [EMAIL PROTECTED] wrote:
Ahh. What would make this really simple is if LiftRules.finder was a
 PF
instead of a straight def, since LiftRules.finder is what actually
 tries
   to
locate the template using ClassLoader.getResourceAsStream currently.
 In
   the
meantime, you might have luck with LiftRules.liftTagProcessing. You
 can
define your own PF that handles surround specially. In particular,
 I'd
   look
at processSurroundElement (and the related findAndMerge and
 processBind)
   in
LiftSession.scala.
 
Derek
 
On Thu, Dec 4, 2008 at 1:27 PM, Tim Perrett [EMAIL PROTECTED]
   wrote:
 
 I am indeed talking about lift:surround :)
 
 I see processSurroundAndInclude and what it does, but what i really
 want to do it set the content of the surround dynamically (from a
 layout i'll store in the DB)
 
 How would one go about doing this?
 
 Cheers
 
 Tim
 
 On Dec 4, 7:01 pm, Derek Chen-Becker [EMAIL PROTECTED]
 wrote:
  Are you talking about lift:surround/ tags? Those are handled in
  LiftSession.processSurroundAndInclude, line 697. Here's some
 example
   code
  for a utility method from an old app that uses it in some
 DispatchPFs
   I
 was
  running:
 
def process (xhtml : NodeSeq) : XmlResponse = {
  val data = lift:surround with=default
  at=content{xhtml}/lift:surround
  XmlResponse(html{
  S.session.open_!.processSurroundAndInclude(S.uri,data)}/html)
}
 
  Derek
 
  On Thu, Dec 4, 2008 at 12:50 PM, Tim Perrett 
 [EMAIL PROTECTED]
 wrote:
 
   Hey guys,
 
   Within lift, I cant seem to find where the content returned
 from
   whatever template mech then gets bound to the layout content?
 
   Can someone point me in the right direction?
 
   Cheers
 
   Tim
 
  --
  Lift, the simply functional web frameworkhttp://liftweb.net
  Collaborative Task Managementhttp://much4.us
  Follow me:http://twitter.com/dpp
  Git some:http://github.com/dpp
 



-- 
Lift, the simply functional web framework http://liftweb.net
Collaborative Task Management http://much4.us
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---