Quantcast

multiple "regions" in 2-phase layout render views

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

multiple "regions" in 2-phase layout render views

Christopher Townson-4
Hi,

I have an app that is using Velocity with a 2-phase layout render (using Spring VelocityLayoutView in this case). However, Spring's layout view effectively restricts you to having just the one "screen_content" area in the layout. What I wanted to be able to do was have an arbitrary number of "regions" defined in the view without having to go the whole Tiles route, which I felt was both a configuration hassle and overkill.

So I found myself writing a new directive (attached) to have layouts constituted from an arbitrary number of "regions".

What I am wondering is whether I am just being really stupid and there is already a straightforward way to achieve the desired result using pre-existing Velocity directives/tools? The #define directive didn't quite cut it here: because render is deferred until reference, the layout decorator cannot reference context properties established within the regions themselves (in my use case: allowing regions to define scripts and stylesheets that are then added to head/end-of-body in the layout decorator).

If this isn't possible with existing Velocity tools/directives then the attached might be useful to other people and/or as an addition to Velocity?

Cheers,

Chris



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: multiple "regions" in 2-phase layout render views

Nathan Bubna
Chris,

The attached was not attached. :) Can you put it in a gist or something?

-nathan

On Fri, Feb 27, 2015 at 1:56 AM, Christopher Townson <
[hidden email]> wrote:

> Hi,
>
> I have an app that is using Velocity with a 2-phase layout render (using
> Spring VelocityLayoutView in this case). However, Spring's layout view
> effectively restricts you to having just the one "screen_content" area in
> the layout. What I wanted to be able to do was have an arbitrary number of
> "regions" defined in the view without having to go the whole Tiles route,
> which I felt was both a configuration hassle and overkill.
>
> So I found myself writing a new directive (attached) to have layouts
> constituted from an arbitrary number of "regions".
>
> What I am wondering is whether I am just being really stupid and there is
> already a straightforward way to achieve the desired result using
> pre-existing Velocity directives/tools? The #define directive didn't quite
> cut it here: because render is deferred until reference, the layout
> decorator cannot reference context properties established within the
> regions themselves (in my use case: allowing regions to define scripts and
> stylesheets that are then added to head/end-of-body in the layout
> decorator).
>
> If this isn't possible with existing Velocity tools/directives then the
> attached might be useful to other people and/or as an addition to Velocity?
>
> Cheers,
>
> Chris
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: multiple "regions" in 2-phase layout render views

Christopher Townson-4
oops :)

good idea, Nathan -- please see
https://gist.github.com/corinthino/44fd09e730d08ab44dfb


On 3 March 2015 at 01:10, Nathan Bubna <[hidden email]> wrote:

> Chris,
>
> The attached was not attached. :) Can you put it in a gist or something?
>
> -nathan
>
> On Fri, Feb 27, 2015 at 1:56 AM, Christopher Townson <
> [hidden email]> wrote:
>
> > Hi,
> >
> > I have an app that is using Velocity with a 2-phase layout render (using
> > Spring VelocityLayoutView in this case). However, Spring's layout view
> > effectively restricts you to having just the one "screen_content" area in
> > the layout. What I wanted to be able to do was have an arbitrary number
> of
> > "regions" defined in the view without having to go the whole Tiles route,
> > which I felt was both a configuration hassle and overkill.
> >
> > So I found myself writing a new directive (attached) to have layouts
> > constituted from an arbitrary number of "regions".
> >
> > What I am wondering is whether I am just being really stupid and there is
> > already a straightforward way to achieve the desired result using
> > pre-existing Velocity directives/tools? The #define directive didn't
> quite
> > cut it here: because render is deferred until reference, the layout
> > decorator cannot reference context properties established within the
> > regions themselves (in my use case: allowing regions to define scripts
> and
> > stylesheets that are then added to head/end-of-body in the layout
> > decorator).
> >
> > If this isn't possible with existing Velocity tools/directives then the
> > attached might be useful to other people and/or as an addition to
> Velocity?
> >
> > Cheers,
> >
> > Chris
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]
> > For additional commands, e-mail: [hidden email]
> >
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: multiple "regions" in 2-phase layout render views

Nathan Bubna
I don't know of any totally straightforward way to achieve this particular
feature set. You could probably just do something like:

---- content.vtl ----
#define( $regionFoo )
  #set( $foo = 'Foo' )
 <p>Foo</p>
#end
#set( $regionFoo = "$regionFoo" )

--- layout.vtl ---
<html>
<head>
  <meta name="foo" content="$!foo">
</head>
<body>
  <div id="foo">
     $!regionFoo
  </div>
</body>
</html>

but that's not as straightforward, of course.

On Mon, Mar 2, 2015 at 11:23 PM, Christopher Townson <
[hidden email]> wrote:

> oops :)
>
> good idea, Nathan -- please see
> https://gist.github.com/corinthino/44fd09e730d08ab44dfb
>
>
> On 3 March 2015 at 01:10, Nathan Bubna <[hidden email]> wrote:
>
> > Chris,
> >
> > The attached was not attached. :) Can you put it in a gist or something?
> >
> > -nathan
> >
> > On Fri, Feb 27, 2015 at 1:56 AM, Christopher Townson <
> > [hidden email]> wrote:
> >
> > > Hi,
> > >
> > > I have an app that is using Velocity with a 2-phase layout render
> (using
> > > Spring VelocityLayoutView in this case). However, Spring's layout view
> > > effectively restricts you to having just the one "screen_content" area
> in
> > > the layout. What I wanted to be able to do was have an arbitrary number
> > of
> > > "regions" defined in the view without having to go the whole Tiles
> route,
> > > which I felt was both a configuration hassle and overkill.
> > >
> > > So I found myself writing a new directive (attached) to have layouts
> > > constituted from an arbitrary number of "regions".
> > >
> > > What I am wondering is whether I am just being really stupid and there
> is
> > > already a straightforward way to achieve the desired result using
> > > pre-existing Velocity directives/tools? The #define directive didn't
> > quite
> > > cut it here: because render is deferred until reference, the layout
> > > decorator cannot reference context properties established within the
> > > regions themselves (in my use case: allowing regions to define scripts
> > and
> > > stylesheets that are then added to head/end-of-body in the layout
> > > decorator).
> > >
> > > If this isn't possible with existing Velocity tools/directives then the
> > > attached might be useful to other people and/or as an addition to
> > Velocity?
> > >
> > > Cheers,
> > >
> > > Chris
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [hidden email]
> > > For additional commands, e-mail: [hidden email]
> > >
> >
>
Loading...