Skip to content

Commit

Permalink
Rename template variables in the Account and Admin Toggle templates t…
Browse files Browse the repository at this point in the history
…o not use underscores.
  • Loading branch information
perlDreamer committed Sep 21, 2010
1 parent 6f4e341 commit f61e8fa
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 13 deletions.
11 changes: 7 additions & 4 deletions docs/gotcha.txt
Expand Up @@ -13,10 +13,13 @@ save you many hours of grief.
code, chances are you'll need to update it to make it work with
WebGUI 8.

* WebGUI now requires the following modules
- Moose
- CHI
- Facebook::Graph
* As part of the migration to Template::Toolkit, we will be changing template
variables from using dots to underscores. All templates using that namespace were
automatically upgraded to use the new variables.

In this version, these templates were updated:
Account Macro template
Admin Toggle Macro template

7.9.8
--------------------------------------------------------------------
Expand Down
14 changes: 14 additions & 0 deletions docs/templates.txt
@@ -0,0 +1,14 @@
This is a running list of template changes made during upgrades. If you have copied the default
templates, you will need to apply these changes manually to your copies.

7.8.0

* Account Macro template variables renamed:
account.url => account_url
account.text => account_text

* AdminToggle Macro template variables renamed:
toggle.url => toggle_url
toggle.text => toggle_text


11 changes: 10 additions & 1 deletion lib/WebGUI/Help/Macro_AdminToggle.pm
Expand Up @@ -6,7 +6,16 @@ our $HELP = {
'admin toggle' => {
title => 'admin toggle title',
body => '',
variables => [ { 'name' => 'toggle.url' }, { 'name' => 'toggle.text' } ],
variables => [
{
name => 'toggle_url',
description => 'toggle.url',
},
{
name => 'toggle_text',
description => 'toggle.text',
},
],
fields => [],
related => []
},
Expand Down
11 changes: 10 additions & 1 deletion lib/WebGUI/Help/Macro_a_account.pm
Expand Up @@ -7,7 +7,16 @@ our $HELP = {
title => 'account title',
body => '',
fields => [],
variables => [ { 'name' => 'account.url' }, { 'name' => 'account.text' } ],
variables => [
{
name => 'account_url',
description => 'account.url',
},
{
name => 'account_text',
description => 'account.text',
}
],
related => []
},

Expand Down
6 changes: 3 additions & 3 deletions lib/WebGUI/Macro/AdminToggle.pm
Expand Up @@ -51,12 +51,12 @@ sub process {
my ($turnOn, $templateName) = @_;
my $i18n = WebGUI::International->new($session,'Macro_AdminToggle');
my %var;
$var{'toggle.text'} = $turnOn || $i18n->get(516);
$var{'toggle_text'} = $turnOn || $i18n->get(516);
if ($session->var->isAdminOn) {
$var{'toggle.url'} = '#'
$var{'toggle_url'} = '#'
}
else {
$var{'toggle.url'} = $session->url->page('op=admin');
$var{'toggle_url'} = $session->url->page('op=admin');
}
my $template = $templateName ? WebGUI::Asset::Template->newByUrl($session, $templateName)
: WebGUI::Asset::Template->newById($session, "PBtmpl0000000000000036");
Expand Down
4 changes: 2 additions & 2 deletions lib/WebGUI/Macro/a_account.pm
Expand Up @@ -44,8 +44,8 @@ sub process {
my @param = @_;
return $session->url->page("op=auth;method=init") if ($param[0] eq "linkonly");
my $i18n = WebGUI::International->new($session,'Macro_a_account');
$var{'account.url'} = $session->url->page('op=auth;method=init');
$var{'account.text'} = $param[0] || $i18n->get(46);
$var{'account_url'} = $session->url->page('op=auth;method=init');
$var{'account_text'} = $param[0] || $i18n->get(46);
if ($param[1]) {
return WebGUI::Asset::Template->newByUrl($session, $param[1])->process(\%var);
} else {
Expand Down
@@ -0,0 +1,20 @@

use WebGUI::Upgrade::Script;

start_step "Rename Account Macro template variables";

my $sth = session->db->read( q|SELECT assetId, revisionDate FROM template where namespace="Macro/a_account"| );
ASSET: while ( my ($assetId, $revisionDate) = $sth->array ) {
my $asset = eval { WebGUI::Asset->newById( session, $assetId, $revisionDate ); };
next ASSET if Exception::Class->caught;
my $template = $asset->get('template');
$template =~ s/account\.url/account_url/msg;
$template =~ s/account\.text/account_text/msg;
$asset->update({
template => $template,
});
}


done;

@@ -0,0 +1,20 @@

use WebGUI::Upgrade::Script;

start_step "Rename AdminToggle Macro template variables";

my $sth = session->db->read( q|SELECT assetId, revisionDate FROM template where namespace="Macro/AdminToggle"| );
ASSET: while ( my ($assetId, $revisionDate) = $sth->array ) {
my $asset = eval { WebGUI::Asset->newById( session, $assetId, $revisionDate ); };
next ASSET if Exception::Class->caught;
my $template = $asset->get('template');
$template =~ s/toggle\.url/toggle_url/msg;
$template =~ s/toggle\.text/toggle_text/msg;
$asset->update({
template => $template,
});
}


done;

2 changes: 1 addition & 1 deletion t/Macro/AdminToggle.t
Expand Up @@ -102,7 +102,7 @@ sub addTemplate {
className => 'WebGUI::Asset::Template',
url => 'admintoggle-test',
namespace => 'Macro/AdminToggle',
template => "HREF=<tmpl_var toggle.url>\nLABEL=<tmpl_var toggle.text>",
template => "HREF=<tmpl_var toggle_url>\nLABEL=<tmpl_var toggle_text>",
id => 'AdminToggleTemplate--Z',
usePacked => 0,
};
Expand Down
2 changes: 1 addition & 1 deletion t/Macro/a_account.t
Expand Up @@ -90,7 +90,7 @@ sub addTemplate {
className => 'WebGUI::Asset::Template',
url => 'a_account-test',
namespace => 'Macro/a_account',
template => "HREF=<tmpl_var account.url>\nLABEL=<tmpl_var account.text>",
template => "HREF=<tmpl_var account_url>\nLABEL=<tmpl_var account_text>",
id => 'testTemplatea_account1',
usePacked => 1,
};
Expand Down

0 comments on commit f61e8fa

Please sign in to comment.