add style parameter to template assets to store a style template id
This commit is contained in:
parent
13e8040190
commit
adb67b2137
2 changed files with 36 additions and 0 deletions
|
|
@ -159,6 +159,21 @@ has param => (
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
=head2 style
|
||||||
|
|
||||||
|
Attach a style template to this template. This will allow you to return the
|
||||||
|
template from a www_ method and have the WebGUI PSGI handler do the processing.
|
||||||
|
|
||||||
|
Accepts an asset ID
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
has style => (
|
||||||
|
is => 'rw',
|
||||||
|
isa => 'Maybe[Str]',
|
||||||
|
);
|
||||||
|
|
||||||
=head1 METHODS
|
=head1 METHODS
|
||||||
|
|
||||||
|
|
@ -579,6 +594,8 @@ Evaluate a template replacing template commands for HTML. If the internal prope
|
||||||
is set to true, the packed, minimized template will be used. Otherwise, the original template
|
is set to true, the packed, minimized template will be used. Otherwise, the original template
|
||||||
will be used.
|
will be used.
|
||||||
|
|
||||||
|
Will also process the style template attached to this template
|
||||||
|
|
||||||
=head3 vars
|
=head3 vars
|
||||||
|
|
||||||
A hash reference containing template variables and loops. Automatically includes the entire WebGUI session.
|
A hash reference containing template variables and loops. Automatically includes the entire WebGUI session.
|
||||||
|
|
@ -627,6 +644,12 @@ sub process {
|
||||||
my $i18n = WebGUI::International->new($session, 'Asset_Template');
|
my $i18n = WebGUI::International->new($session, 'Asset_Template');
|
||||||
$output = sprintf $i18n->get('template error').$e->error, $self->getUrl, $self->getId;
|
$output = sprintf $i18n->get('template error').$e->error, $self->getUrl, $self->getId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Process the style template
|
||||||
|
if ( $self->style ) {
|
||||||
|
$output = $self->session->style->process( $output, $self->style );
|
||||||
|
}
|
||||||
|
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,19 @@ ok($output =~ m/\b(?:XY){5}\b/, "process() - loops");
|
||||||
ok($output =~ m/\bHUEG SUCCESS\b/, "process() merges with setParam" );
|
ok($output =~ m/\bHUEG SUCCESS\b/, "process() merges with setParam" );
|
||||||
$template->deleteParam( 'setParam_var' );
|
$template->deleteParam( 'setParam_var' );
|
||||||
|
|
||||||
|
# Test with a style template
|
||||||
|
my $style = $importNode->addChild({
|
||||||
|
className => 'WebGUI::Asset::Template',
|
||||||
|
title => 'test style',
|
||||||
|
namespace => 'style',
|
||||||
|
template => '<IGOTSTYLE><tmpl_var body.content></IGOTSTYLE>',
|
||||||
|
parser => 'WebGUI::Asset::Template::HTMLTemplate',
|
||||||
|
});
|
||||||
|
$template->style( $style->getId );
|
||||||
|
$output = $template->process({});
|
||||||
|
ok( $output =~ m{^<IGOTSTYLE>.+</IGOTSTYLE>$}, 'style template is added' );
|
||||||
|
$template->style( undef );
|
||||||
|
|
||||||
# See if template listens the Accept header
|
# See if template listens the Accept header
|
||||||
$session->request->header('Accept' => 'application/json');
|
$session->request->header('Accept' => 'application/json');
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue