aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App/View
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet/App/View')
-rw-r--r--perllib/FixMyStreet/App/View/Email.pm44
-rw-r--r--perllib/FixMyStreet/App/View/Web.pm85
2 files changed, 129 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/App/View/Email.pm b/perllib/FixMyStreet/App/View/Email.pm
new file mode 100644
index 000000000..86d5c1d60
--- /dev/null
+++ b/perllib/FixMyStreet/App/View/Email.pm
@@ -0,0 +1,44 @@
+package FixMyStreet::App::View::Email;
+use base 'Catalyst::View::TT';
+
+use strict;
+use warnings;
+
+use mySociety::Locale;
+use FixMyStreet;
+
+__PACKAGE__->config(
+ TEMPLATE_EXTENSION => '.txt',
+ INCLUDE_PATH => [ #
+ FixMyStreet->path_to( 'templates', 'email', 'default' ),
+ ],
+ ENCODING => 'utf8',
+ render_die => 1,
+ expose_methods => ['loc'],
+);
+
+=head1 NAME
+
+FixMyStreet::App::View::Email - 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);
+}
+
+1;
+
diff --git a/perllib/FixMyStreet/App/View/Web.pm b/perllib/FixMyStreet/App/View/Web.pm
new file mode 100644
index 000000000..75ca4dd81
--- /dev/null
+++ b/perllib/FixMyStreet/App/View/Web.pm
@@ -0,0 +1,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;
+