[Dancer-users] get template command to ignore layout

David Precious davidp at preshweb.co.uk
Tue Aug 3 12:48:26 CEST 2010

On Tuesday 03 August 2010 11:19:25 David Holden wrote:
> Hello, I was wondering is it possible to get the template command to
> ignore the layout, e.g.
> here I want it to use the layout
>     template 'index' => $tt2_ds;
> but here
>    template 'table_result' => $tt2_ds;
> I want it to just return the template contents alone,

Indeed it is - the template keyword takes a third param which is a hashref of 
options - you can disable the layout there with:

template 'table_result => $tt2_ds, { layout => undef };

This wasn't particularly clearly documented, but will be with the next Dancer 
release, as I already added a direct mention of it to the docs a few days ago:


> i.e. not wrapped
> by the layout - for an ajax response.

For that kind of thing, you might want to look at Dancer::Serializer to take 
care of serialising data (that sounds like what you're trying to do)


Dave P

David Precious <davidp at preshweb.co.uk>
http://blog.preshweb.co.uk/    www.preshweb.co.uk/twitter
www.preshweb.co.uk/linkedin    www.preshweb.co.uk/facebook
www.preshweb.co.uk/identica    www.lyricsbadger.co.uk

  "Programming is like sex. One mistake and you have to support 
  it for the rest of your life". (Michael Sinz)

More information about the Dancer-users mailing list