71 |
|
|
72 |
my $text = $tt->apply( |
my $text = $tt->apply( |
73 |
template => 'text.tt', |
template => 'text.tt', |
74 |
data => $ds |
data => $ds, |
75 |
|
record_uri => 'database/prefix/mfn', |
76 |
); |
); |
77 |
|
|
78 |
It also has follwing template toolikit filter routies defined: |
It also has follwing template toolikit filter routies defined: |
224 |
|
|
225 |
$args->{'search'} = tt_filter_search($args); |
$args->{'search'} = tt_filter_search($args); |
226 |
|
|
227 |
|
=head3 load_rec |
228 |
|
|
229 |
|
Used mostly for onClick events like this: |
230 |
|
|
231 |
|
<a href="#" onClick="[% load_rec( record_uri, 'template_name.tt') %]>foo</a> |
232 |
|
|
233 |
|
It will automatically do sanity checking and create correct JavaScript code. |
234 |
|
|
235 |
|
=cut |
236 |
|
|
237 |
|
$args->{'load_rec'} = sub { |
238 |
|
my @errors; |
239 |
|
|
240 |
|
my $record_uri = shift or push @errors, "record_uri missing"; |
241 |
|
my $template = shift or push @errors, "template missing"; |
242 |
|
|
243 |
|
if ($record_uri !~ m#^[^/]+/[^/]+/[^/]+$#) { |
244 |
|
push @errors, "invalid format of record_uri: $record_uri"; |
245 |
|
} |
246 |
|
|
247 |
|
if (@errors) { |
248 |
|
return "Logger.error('errors in load_rec: " . join(", ", @errors) . "'); return false;"; |
249 |
|
} else { |
250 |
|
return "load_rec('$record_uri','$template'); return false;"; |
251 |
|
} |
252 |
|
}; |
253 |
|
|
254 |
|
=head3 load_template |
255 |
|
|
256 |
|
Used to re-submit search request and load results in different template |
257 |
|
|
258 |
|
<a href="#" onClick="[% load_template( 'template_name.tt' ) %]">bar</a> |
259 |
|
|
260 |
|
=cut |
261 |
|
|
262 |
|
$args->{'load_template'} = sub { |
263 |
|
my $template = shift or return "Logger.error('load_template missing template name!'); return false;"; |
264 |
|
return "load_template($template); return false;"; |
265 |
|
}; |
266 |
|
|
267 |
my $out; |
my $out; |
268 |
|
|
269 |
$self->{'tt'}->process( |
$self->{'tt'}->process( |