The way template rendering works in Dancer (and I know you know this, but I need to set the ground for the explanation) is that it will render the template, then separately render the layout with the rendered template as the "content" in the layout.
The problem with this is that these two are not connected. The reason is also because it was built for template systems that don't support layouts. However, some of them do.
Template Toolkit supports the WRAPPER option for layouts. You can ask Dancer to not serve a layout and then ask Template Toolkit to use the WRAPPER method to render the content in a layout.
Then you can set META variables in order to control variables that will be available in the wrapper (layout) layer.
Here's the entry in the cookbook:
Since the auto pages render templates, this would work in them too.