Make template path customizable
authorMarius Gavrilescu <marius@ieval.ro>
Mon, 7 Jul 2014 17:58:57 +0000 (20:58 +0300)
committerMarius Gavrilescu <marius@ieval.ro>
Mon, 7 Jul 2014 17:58:57 +0000 (20:58 +0300)
edwardng
lib/App/EdwardNG.pm

index a300792eeec5e3883abd8465f4257191737d251f..7e1363f2cb05e07c41d6e0a56f1e9971949e626f 100755 (executable)
--- a/edwardng
+++ b/edwardng
@@ -51,6 +51,10 @@ Path to GnuPG homedir.
 
 Private key passphrase.
 
+=item B<--tmpl-path>=I<path>
+
+Path to the template directory. Users of the default templates can select the language with this argument. Available languages: en. Defaults to B<--tmpl-path=en>.
+
 =item B<--use-agent>, B<--no-use-agent>
 
 If B<--use-agent>, use L<gpg-agent(1)>. Defaults to B<--no-gpg-agent>.
@@ -87,6 +91,10 @@ Corresponds to B<--keydir>.
 
 Corresponds to B<--passphrase>.
 
+=item EDWARDNG_TMPL_PATH
+
+Corresponds to B<--tmpl-path>.
+
 =item EDWARDNG_USE_AGENT
 
 Corresponds to B<--use-agent> (if true) and B<--no-use-agent> (if false).
index 2d81020ea24ca6a287929f1b683cf3dc0844be3c..9a01dc03458e4a19f5b6c64e2f4cf402a4951cb9 100644 (file)
@@ -9,6 +9,7 @@ our @EXPORT = qw/process_message/;
 
 use Email::Sender::Simple qw/sendmail/;
 use File::Slurp qw/read_file/;
+use File::Spec::Functions qw/rel2abs/;
 use Getopt::Long;
 use MIME::Entity;
 use MIME::Parser;
@@ -95,8 +96,10 @@ sub run {
                'key=s'         => \$ENV{EDWARDNG_KEY},
                'keydir=s'      => \$ENV{EDWARDNG_KEYDIR},
                'passphrase=s'  => \$ENV{EDWARDNG_PASSPHRASE},
+               'tmpl-path=s'   => \$ENV{EDWARDNG_TMPL_PATH},
                'use-agent!'    => \$ENV{EDWARDNG_USE_AGENT},
        );
+       my $tmpl_path = $ENV{EDWARDNG_TMPL_PATH} // 'en';
 
        my $parser = MIME::Parser->new;
        $parser->decode_bodies(0);
@@ -112,7 +115,7 @@ sub run {
 
        $params{plaintext} = first_part $params{decrypted} if $params{decrypted};
 
-       my $tt = Template->new(INCLUDE_PATH => 'tmpl/en');
+       my $tt = Template->new(INCLUDE_PATH => rel2abs $tmpl_path, 'tmpl');
        my $data;
        $tt->process($tmpl, \%params, \$data);
        my $email = MIME::Entity->build(
This page took 0.012049 seconds and 4 git commands to generate.