diff --git a/lib/WebGUI/Asset/Template.pm b/lib/WebGUI/Asset/Template.pm index f10db7568..528ee87dc 100644 --- a/lib/WebGUI/Asset/Template.pm +++ b/lib/WebGUI/Asset/Template.pm @@ -85,6 +85,10 @@ sub definition { fieldType=>'selectList', defaultValue=>[$session->config->get("defaultTemplateParser")] }, + headBlock=>{ + fieldType=>"codearea", + defaultValue=>undef + }, namespace=>{ fieldType=>'combo', defaultValue=>undef @@ -245,6 +249,21 @@ sub indexContent { } +#------------------------------------------------------------------- + +=head2 prepare ( ) + +This method sets the tags from the head block parameter of the template into the HTML head block in the style. You only need to call this method if you're using the HTML streaming features of WebGUI, like is done in the prepareView()/view()/www_view() methods of WebGUI assets. + +=cut + +sub prepare { + my $self = shift; + $self->{_prepared} = 1; + $self->session->style->setRawHeadTags($self->get("headBlock")); +} + + #------------------------------------------------------------------- =head2 process ( vars ) @@ -260,6 +279,7 @@ A hash reference containing template variables and loops. Automatically includes sub process { my $self = shift; my $vars = shift; + $self->prepare unless ($self->{_prepared}); return $self->getParser($self->session, $self->get("parser"))->process($self->get("template"), $vars); } diff --git a/lib/WebGUI/Asset/Wobject.pm b/lib/WebGUI/Asset/Wobject.pm index 69a782b16..5a6ccab10 100644 --- a/lib/WebGUI/Asset/Wobject.pm +++ b/lib/WebGUI/Asset/Wobject.pm @@ -393,6 +393,21 @@ sub moveCollateralUp { $self->session->db->commit; } +#------------------------------------------------------------------- + +=head2 prepareView ( ) + +See WebGUI::Asset::prepareView() for details. + +=cut + +sub prepareView { + my $self = shift; + my $template = WebGUI::Asset::Template->new($self->session, $self->get("templateId")); + $template->prepare; +} + + #------------------------------------------------------------------- sub processPropertiesFromFormPost { my $self = shift; diff --git a/lib/WebGUI/Session/Style.pm b/lib/WebGUI/Session/Style.pm index dfc36b5c0..43a39ab2c 100644 --- a/lib/WebGUI/Session/Style.pm +++ b/lib/WebGUI/Session/Style.pm @@ -214,6 +214,7 @@ if ($self->session->user->isInGroup(2)) { } WebGUI::Macro::process(\$output); my $macroHeadTags = $self->generateAdditionalHeadTags(); + WebGUI::Macro::process(\$macroHeadTags); $output =~ s/\<\!--morehead--\>/$macroHeadTags/; if ($self->session->errorHandler->canShowDebug()) { $output .= $self->session->errorHandler->showDebug();