1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
package FixMyStreet::App::View::Web;
use base 'Catalyst::View::TT';
use strict;
use warnings;
use mySociety::Locale;
use FixMyStreet;
__PACKAGE__->config(
TEMPLATE_EXTENSION => '.html',
INCLUDE_PATH => [ #
FixMyStreet->path_to( 'templates', 'web', 'default' ),
],
ENCODING => 'utf8',
render_die => 1,
expose_methods => [ 'loc', 'nget', 'tprintf', ],
);
=head1 NAME
FixMyStreet::App::View::Web - TT View for FixMyStreet::App
=head1 DESCRIPTION
TT View for FixMyStreet::App.
=cut
=head2 loc
[% loc('Some text to localize') %]
Passes the text to the localisation engine for translations.
=cut
sub loc {
my ( $self, $c, @args ) = @_;
return _(@args);
}
=head2 nget
[% nget( 'singular', 'plural', $number ) %]
Use first or second srting depending on the number.
=cut
sub nget {
my ( $self, $c, @args ) = @_;
return mySociety::Locale::nget(@args);
}
=head2 tprintf
[% tprintf( 'foo %s bar', 'insert' ) %]
sprintf (different name to avoid clash)
=cut
sub tprintf {
my ( $self, $c, $format, @args ) = @_;
return sprintf $format, @args;
}
=head2 display_crossell_advert
[% display_crossell_advert( email, name ) %]
Displays a crosssell advert if permitted by the cobrand.
=cut
sub display_crossell_advert {
my ( $self, $c, $email, $name ) = @_;
return unless $c->cobrand->allow_crosssell_adverts();
return CrossSell::display_advert( $c->req, $email, $name );
}
1;
|