Skip to content

Commit

Permalink
Allow template engine selection per page.
Browse files Browse the repository at this point in the history
  • Loading branch information
racke committed Dec 12, 2010
1 parent 2e83697 commit 5eeea24
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions lib/WellWell/Compose.pm
Expand Up @@ -49,7 +49,7 @@ sub dots2hash {

sub compose {
my ($template, $opt, $body) = @_;
my (%acl, %forms, %engines, $template_file, $container);
my (%acl, %forms, %engines, $default_engine, $template_file, $container);

if ($opt->{acl}) {
# check permissions first
Expand Down Expand Up @@ -91,8 +91,25 @@ sub compose {
}
}

if ($opt->{engine}) {
%engines = %{$opt->{engine}};
# template engine selection
if (exists $opt->{engine}) {
if (ref $opt->{engine} eq 'HASH') {
# engine by component
%engines = %{$opt->{engine}};

if (exists $engines{all}) {
$default_engine = delete $engines{all};
}
else {
$default_engine = 'itl';
}
}
else {
$default_engine = $opt->{engine};
}
}
else {
$default_engine = 'itl';
}

$opt->{body} ||= $body;
Expand Down Expand Up @@ -238,7 +255,7 @@ sub compose {
$engine_name = $engines{$name};
}
else {
$engine_name = 'itl';
$engine_name = $default_engine;
}
delete $Vend::Session->{engine}->{$engine_name};
unless ($Vend::Session->{engine}->{$engine_name} ||= load_engine($engine_name, database_exists_ref('products')->dbh())) {
Expand Down

0 comments on commit 5eeea24

Please sign in to comment.