[Dancer-users] config.yml options not visible to Dancer::Template::HtmlTemplate
Stephen Fenwick-Paul
stephen at activeg.org
Sun Mar 18 19:29:13 CET 2012
I'm not sure this is bug. I use Mason for template engine. I just pass
config values into the template like any other value.
I use the before_template for passing in common stuff:
hook before_template_render => sub {
my ($tokens) = @_;
$tokens->{fb_app_id} = config->{facebook}->{app_id};
}
On 18 March 2012 18:23, GJ <gj at freeshell.org> wrote:
> Hi all,
>
> While I can set my needed options for HTML::Template in config.yml per the
> documentation/guidance of the list, it never reaches
> Dancer::Template::HtmlTemplate. The issue is here, in HtmlTemplate.pm, in
> in the render method :
>
> ----
> my $ht = HTML::Template->new(
> filename => $template,
> die_on_bad_params => 0, # Required, as we pass through other params
> too
> %{$self->config}
> );
> $ht->param($tokens);
> return $ht->output;
> ----
>
> The problem is that $self->config is empty here. I'm using version 0.06.
>
> Also, I don't necessarily want die_on_bad_params hard coded that way.
>
> Besides that, what I really miss is the ability to do this sort of thing:
>
> ----
> if (condition) {
> set a certain param for the template
> } else {
> set some other param
> }
> ----
>
> I can't do this because the module doesn't inherit the param method from
> HTML::Template. Can't Dancer be wangled into setting template tokens in
> multiple places for a given route, or must it happen all at once?
>
> Side note -- whitespace is apparently syntactically significant in YAML. Of
> what possible benefit is that?
>
> Clues or opinions welcome.
>
> Thanks,
> GJ
> _______________________________________________
> Dancer-users mailing list
> Dancer-users at perldancer.org
> http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
More information about the Dancer-users
mailing list