Quantcast

Choose template in a custom Loc

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Choose template in a custom Loc

Misha Korablin
I'm writing a custom Loc for a page and want to choose a different
template in <lift:surround> if a certain URL parameter is present.

Basically, I have a template like this:

<lift:surround with="t1" at="content">
...
</lift:surround>

And at runtime I want to substitute t1 for t2 if necessary and leave
everything inside <lift:surround> intact.

How can I do this?


Misha

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


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Choose template in a custom Loc

Mads Hartmann
I believe you might be able to solve your problem with a snippet :) Like so;

<lift:MySnippet.dynamicTemplatePicking>
        <lift:surround dynamic:template="" at="content">

        </lift:surround>
</lift:MySnippet.dynamicTemplatePicking>

and in you snippet

Class MySnippet {
       
        def dynamicTemplatePicking(xhtml :NodeSeq) :NodeSeq = {
                bind("dynamic", xhtml, AttrBindParam("template", Text("t1 or t2 would go here"), "with"))
        }
}

Disclaimer: This code was written in mail.app and is pretty likely to contain errors ;)


On 13/01/2010, at 20.37, Misha Korablin wrote:

> I'm writing a custom Loc for a page and want to choose a different
> template in <lift:surround> if a certain URL parameter is present.
>
> Basically, I have a template like this:
>
> <lift:surround with="t1" at="content">
> ...
> </lift:surround>
>
> And at runtime I want to substitute t1 for t2 if necessary and leave
> everything inside <lift:surround> intact.
>
> How can I do this?
>
>
> Misha
> --
> You received this message because you are subscribed to the Google Groups "Lift" group.
> To post to this group, send email to [hidden email].
> To unsubscribe from this group, send email to [hidden email].
> For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.
>
>

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


Loading...