176 |
sub make_viewfragment ($$) { |
sub make_viewfragment ($$) { |
177 |
my ($src, $Info) = @_; |
my ($src, $Info) = @_; |
178 |
my $r = ''; |
my $r = ''; |
179 |
my $name = $src->get_attribute_value ('Name'); |
my $body = <<EOH; |
180 |
$name =~ tr/-/_/; |
{ |
|
## SuikaWiki 2 Interface |
|
|
# $r .= qq(SuikaWiki::View->template (@{[literal $name]}) |
|
|
# ->add_line (@{[literal $src->get_attribute_value ('Formatting')]});\n); |
|
|
## SuikaWiki 3 Interface |
|
|
$r .= <<EOH; |
|
|
push \@{\$SuikaWiki::View::Implementation::TemplateFragment{@{[literal $name]}}}, { |
|
181 |
Main => @{[literal $src->get_attribute_value ('Formatting')]}, |
Main => @{[literal $src->get_attribute_value ('Formatting')]}, |
182 |
Order => @{[0+$src->get_attribute_value ('Order')]}, |
Order => @{[0+$src->get_attribute_value ('Order')]}, |
183 |
Description => [@{[m13ed_val_list $src, 'Description']}], |
Description => [@{[m13ed_val_list $src, 'Description']}], |
184 |
}; |
}; |
185 |
EOH |
EOH |
186 |
push @{$Info->{provide}->{viewfragment}}, |
## Recommended format |
187 |
{Name => $src->get_attribute ('Name')->value}; |
my $name = $src->get_attribute_value ('Template'); |
188 |
|
if (ref ($name) and @$name > 1) { |
189 |
|
$r .= qq({my \$def = $body;\n); |
190 |
|
for (@$name) { |
191 |
|
my $name = $_; $name =~ tr/-/_/; |
192 |
|
$r .= qq(push \@{\$SuikaWiki::View::Implementation::TemplateFragment{@{[literal $name]}}}, \$def;\n); |
193 |
|
push @{$Info->{provide}->{viewfragment}}, {Name => $name}; |
194 |
|
} |
195 |
|
$r .= qq(}\n); |
196 |
|
} else { ## Obsoleted format |
197 |
|
$name = ref $name ? $name->[0] : $src->get_attribute_value ('Name'); |
198 |
|
$name =~ tr/-/_/; |
199 |
|
$r .= qq(push \@{\$SuikaWiki::View::Implementation::TemplateFragment{@{[literal $name]}}}, $body); |
200 |
|
push @{$Info->{provide}->{viewfragment}}, {Name => $name}; |
201 |
|
} |
202 |
$r; |
$r; |
203 |
} |
} |
204 |
|
|