pax_global_header00006660000000000000000000000064117756466640014540gustar00rootroot0000000000000052 comment=4982aec287d056c1164cf62065967eda989a72e5 perl-MojoX-Renderer-Xslate-0.08/000075500000000000000000000000001177564666400164635ustar00rootroot00000000000000perl-MojoX-Renderer-Xslate-0.08/.gitignore000064400000000000000000000001331177564666400204500ustar00rootroot00000000000000MANIFEST.bak MYMETA.* Makefile Makefile.old MojoX-Renderer-Xslate-* blib/ pm_to_blib t/tmp perl-MojoX-Renderer-Xslate-0.08/Changes000064400000000000000000000015531177564666400177620ustar00rootroot00000000000000Revision history for MojoX-Renderer-Xslate 0.08 Fri Jul 6 20:39:25 UTC 2012 - Updated to handle another backwards-incompatible API change. (ISHIGAKI) 0.07 Thu Mar 29 06:44:45 UTC 2012 - Used valid version of Mojolicious. 0.06 Thu Mar 29 06:36:16 UTC 2012 - Required newer version of Mojolicious. 0.05 Wed Mar 28 07:52:55 UTC 2012 - Updated to use newer method instead of deprecated method. (GARU) 0.04 Sat Dec 4 12:29:27 UTC 2010 - Updated test to reflect that a 500 error can produce either an error string or no content, depending upon the environment or prereq versions. 0.03 Fri Dec 3 19:28:43 UTC 2010 - Updated test case to accomodate change in Xslate. 0.02 Wed Nov 3 10:17:09 UTC 2010 - Added support for __DATA__ sections by default. (GFUJI) 0.01 Sun Aug 15 20:37:52 UTC 2010 - Initial distribution. perl-MojoX-Renderer-Xslate-0.08/MANIFEST000064400000000000000000000004401177564666400176120ustar00rootroot00000000000000Changes lib/Mojolicious/Plugin/XslateRenderer.pm lib/MojoX/Renderer/Xslate.pm Makefile.PL MANIFEST This list of files MANIFEST.SKIP README t/00_compile.t t/default.t t/lite_app.t t/templates/foo.html.tx xt/kwalitee.t xt/perlcritic.t xt/perlcriticrc xt/pod.t xt/pod_coverage.t xt/vars.t perl-MojoX-Renderer-Xslate-0.08/MANIFEST.SKIP000064400000000000000000000017571177564666400203730ustar00rootroot00000000000000 #!start included /opt/local/lib/perl5/5.12.1/ExtUtils/MANIFEST.SKIP # Avoid version control files. \bRCS\b \bCVS\b \bSCCS\b ,v$ \B\.svn\b \B\.git\b \B\.gitignore\b \b_darcs\b \B\.cvsignore$ # Avoid VMS specific MakeMaker generated files \bDescrip.MMS$ \bDESCRIP.MMS$ \bdescrip.mms$ # Avoid Makemaker generated and utility files. \bMANIFEST\.bak \bMakefile$ \bblib/ \bMakeMaker-\d \bpm_to_blib\.ts$ \bpm_to_blib$ \bblibdirs\.ts$ # 6.18 through 6.25 generated this # Avoid Module::Build generated and utility files. \bBuild$ \b_build/ \bBuild.bat$ \bBuild.COM$ \bBUILD.COM$ \bbuild.com$ # Avoid temp and backup files. ~$ \.old$ \#$ \b\.# \.bak$ \.tmp$ \.# \.rej$ # Avoid OS-specific files/dirs # Mac OSX metadata \B\.DS_Store # Mac OSX SMB mount metadata files \B\._ # Avoid Devel::Cover and Devel::CoverX::Covered files. \bcover_db\b \bcovered\b # Avoid MYMETA files ^MYMETA\. #!end included /opt/local/lib/perl5/5.12.1/ExtUtils/MANIFEST.SKIP # Ignore the generated template cache. t/tmp/ perl-MojoX-Renderer-Xslate-0.08/Makefile.PL000064400000000000000000000026151177564666400204410ustar00rootroot00000000000000use strict; use warnings; use ExtUtils::MakeMaker; my %conf = ( NAME => 'MojoX::Renderer::Xslate', AUTHOR => 'gray ', LICENSE => 'perl', VERSION_FROM => 'lib/MojoX/Renderer/Xslate.pm', ABSTRACT_FROM => 'lib/MojoX/Renderer/Xslate.pm', PREREQ_PM => { parent => 0, Mojolicious => 3.0, 'Text::Xslate' => 0.2013, 'Try::Tiny' => 0, }, BUILD_REQUIRES => { 'Test::Mojo' => 0, 'Test::More' => 0.82, }, META_MERGE => { resources => { repository => 'http://github.com/gray/mojox-renderer-xslate', }, }, dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', }, clean => { FILES => 'MojoX-Renderer-Xslate-*' }, ); my $eumm_version = do { no warnings 'numeric'; eval $ExtUtils::MakeMaker::VERSION; }; delete $conf{META_MERGE} if $eumm_version < 6.46; $conf{PREREQ_PM} = { %{ $conf{PREREQ_PM} || {} }, %{ delete $conf{BUILD_REQUIRES} }, } if ($conf{BUILD_REQUIRES} and $eumm_version < 6.5503); WriteMakefile(%conf); sub MY::postamble { return <<" MAKE_FRAG"; authortest: \t\$(MAKE) -e \$(TEST_TYPE) TEST_FILES="xt/*.t" MAKE_FRAG } sub MY::dist_test { my $self = shift; return $self->MM::dist_test . <<" MAKE_FRAG"; \tcd \$(DISTVNAME) && \$(MAKE) authortest \$(PASTHRU) MAKE_FRAG } perl-MojoX-Renderer-Xslate-0.08/README000064400000000000000000000010531177564666400173420ustar00rootroot00000000000000MojoX-Renderer-Xslate ===================== This module provides a Text::Xslate renderer for Mojo. INSTALLATION To install this module type the following: perl Makefile.PL make make test make install DEPENDENCIES This module requires these other modules and libraries: Mojo parent Text::Xslate Test::Mojo Test::More Try::Tiny COPYRIGHT AND LICENCE Copyright (C) 2010-2012 by gray This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl-MojoX-Renderer-Xslate-0.08/lib/000075500000000000000000000000001177564666400172315ustar00rootroot00000000000000perl-MojoX-Renderer-Xslate-0.08/lib/MojoX/000075500000000000000000000000001177564666400202655ustar00rootroot00000000000000perl-MojoX-Renderer-Xslate-0.08/lib/MojoX/Renderer/000075500000000000000000000000001177564666400220335ustar00rootroot00000000000000perl-MojoX-Renderer-Xslate-0.08/lib/MojoX/Renderer/Xslate.pm000064400000000000000000000070001177564666400236260ustar00rootroot00000000000000package MojoX::Renderer::Xslate; use strict; use warnings; use parent qw(Mojo::Base); use File::Spec (); use Mojo::Loader; use Text::Xslate (); use Try::Tiny; our $VERSION = '0.08'; $VERSION = eval $VERSION; __PACKAGE__->attr('xslate'); sub build { my $self = shift->SUPER::new(@_); $self->_init(@_); return sub { $self->_render(@_) }; } sub _init { my ($self, %args) = @_; my $app = $args{mojo} || $args{app}; my $cache_dir; my @path = $app->home->rel_dir('templates'); if ($app) { $cache_dir = $app->home->rel_dir('tmp/compiled_templates'); push @path, Mojo::Loader->new->data( $app->renderer->classes->[0], ); } else { $cache_dir = File::Spec->tmpdir; } my %config = ( cache_dir => $cache_dir, path => \@path, %{ $args{template_options} || {} }, ); $self->xslate(Text::Xslate->new(\%config)); return $self; } sub _render { my ($self, $renderer, $c, $output, $options) = @_; my $name = $c->stash->{'template_name'} || $renderer->template_name($options); my %params = (%{$c->stash}, c => $c); try { $$output = $self->xslate->render($name, \%params); } catch { my $err = $_; $c->app->log->error(qq(Template error in "$name": $err)); $c->render_exception($err); $$output = ''; return 0; }; return 1; } 1; __END__ =head1 NAME MojoX::Renderer::Xslate - Text::Xslate renderer for Mojo =head1 SYNOPSIS sub startup { .... # Via mojolicious plugin $self->plugin('xslate_renderer'); # or manually use MojoX::Renderer::Xslate; my $xslate = MojoX::Renderer::Xslate->build( mojo => $self, template_options => { }, ); $self->renderer->add_handler(tx => $xslate); } =head1 DESCRIPTION The C module is called by C for any matching template. =head1 METHODS =head2 build $renderer = MojoX::Renderer::Xslate->build(...) This method returns a handler for the Mojo renderer. Supported parameters are: =over =item mojo C currently uses a C parameter pointing to the base class object (C). =item template_options A hash reference of options that are passed to Text::Xslate->new(). =back =head1 SEE ALSO L, L =head1 REQUESTS AND BUGS Please report any bugs or feature requests to L. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. =head1 SUPPORT You can find documentation for this module with the perldoc command. perldoc MojoX::Renderer::Xslate You can also look for information at: =over =item * GitHub Source Repository L =item * AnnoCPAN: Annotated CPAN documentation L =item * CPAN Ratings L =item * RT: CPAN's request tracker L =item * Search CPAN L =back =head1 COPYRIGHT AND LICENSE Copyright (C) 2010-2012 gray , all rights reserved. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 AUTHOR gray, =cut perl-MojoX-Renderer-Xslate-0.08/lib/Mojolicious/000075500000000000000000000000001177564666400215255ustar00rootroot00000000000000perl-MojoX-Renderer-Xslate-0.08/lib/Mojolicious/Plugin/000075500000000000000000000000001177564666400227635ustar00rootroot00000000000000perl-MojoX-Renderer-Xslate-0.08/lib/Mojolicious/Plugin/XslateRenderer.pm000064400000000000000000000021421177564666400262470ustar00rootroot00000000000000package Mojolicious::Plugin::XslateRenderer; use strict; use warnings; use parent qw(Mojolicious::Plugin); use MojoX::Renderer::Xslate; sub register { my ($self, $app, $args) = @_; $args ||= {}; my $xslate = MojoX::Renderer::Xslate->build(app => $app, %$args); $app->renderer->add_handler(tx => $xslate); } 1; __END__ =head1 NAME Mojolicious::Plugin::Xslate - Text::Xslate plugin =head1 SYNOPSIS # Mojolicious $self->plugin('xslate_renderer'); $self->plugin(xslate_renderer => { template_options => { syntax => 'TTerse', ...} }); # Mojolicious::Lite plugin 'xslate_renderer'; plugin xslate_renderer => { template_options => { syntax => 'TTerse', ...} }; =head1 DESCRIPTION L is a simple loader for L. =head1 METHODS L inherits all methods from L and overrides the following ones: =head2 register $plugin->register Registers renderer in L application. =head1 SEE ALSO L, L =cut perl-MojoX-Renderer-Xslate-0.08/t/000075500000000000000000000000001177564666400167265ustar00rootroot00000000000000perl-MojoX-Renderer-Xslate-0.08/t/00_compile.t000064400000000000000000000002341177564666400210410ustar00rootroot00000000000000use strict; use warnings; use Test::More tests => 2; BEGIN { use_ok qw(MojoX::Renderer::Xslate); use_ok qw(Mojolicious::Plugin::XslateRenderer); } perl-MojoX-Renderer-Xslate-0.08/t/default.t000064400000000000000000000005161177564666400205410ustar00rootroot00000000000000use strict; use warnings; use Test::More tests => 3; use Test::Mojo; use Mojolicious::Lite; # Silence app->log->level('fatal'); plugin 'xslate_renderer'; get '/' => 'index'; my $t = Test::Mojo->new; $t->get_ok('/')->status_is(200)->content_is("Hello, Xslate world!\n"); __DATA__ @@ index.html.tx Hello, <: "Xslate" :> world! perl-MojoX-Renderer-Xslate-0.08/t/lite_app.t000064400000000000000000000024431177564666400207130ustar00rootroot00000000000000use strict; use warnings; use Test::More tests => 14; use Test::Mojo; use Mojolicious::Lite; # Silence app->log->level('fatal'); plugin 'xslate_renderer'; my $xslate = MojoX::Renderer::Xslate->build( mojo => app, template_options => { syntax => 'TTerse', path => [ Mojo::Loader->new->data(__PACKAGE__) ], }, ); app->renderer->add_handler(tt => $xslate); get '/exception' => 'error'; get '/with_include' => 'include'; get '/with_wrapper' => 'wrapper'; get '/foo/:message' => 'index'; get '/on-disk' => 'foo'; my $t = Test::Mojo->new; $t->get_ok('/exception')->status_is(500)->content_like(qr/error|^$/i); $t->get_ok('/foo/hello')->content_like(qr/^hello\s*$/); $t->get_ok('/with_include')->content_like(qr/^Hello\s*Include!Hallo\s*$/); $t->get_ok('/with_wrapper')->content_like(qr/^wrapped\s*$/); $t->get_ok('/on-disk')->content_is(4); $t->get_ok('/not_found')->status_is(404)->content_like(qr/not found/i); __DATA__ @@ error.html.tt [% 1 + 1 %%] @@ index.html.tt [%- message -%] @@ include.inc Hello @@ includes/include.inc Hallo @@ include.html.tt [%- INCLUDE 'include.inc' -%] Include! [%- INCLUDE 'includes/include.inc' -%] @@ layouts/layout.html.tt w[%- content -%]d @@ wrapper.html.tt [%- WRAPPER 'layouts/layout.html.tt' -%] rappe [%- END -%] perl-MojoX-Renderer-Xslate-0.08/t/templates/000075500000000000000000000000001177564666400207245ustar00rootroot00000000000000perl-MojoX-Renderer-Xslate-0.08/t/templates/foo.html.tx000064400000000000000000000000161177564666400230240ustar00rootroot00000000000000<:- 2 + 2 -:> perl-MojoX-Renderer-Xslate-0.08/xt/000075500000000000000000000000001177564666400171165ustar00rootroot00000000000000perl-MojoX-Renderer-Xslate-0.08/xt/kwalitee.t000064400000000000000000000002621177564666400211100ustar00rootroot00000000000000use strict; use warnings; use Test::More; eval { require Test::Kwalitee; Test::Kwalitee->import(); 1 } or do { plan skip_all => 'Test::Kwalitee not installed; skipping'; }; perl-MojoX-Renderer-Xslate-0.08/xt/perlcritic.t000064400000000000000000000003721177564666400214450ustar00rootroot00000000000000use strict; use warnings; use Test::More; eval { require Test::Perl::Critic; 1 } or do { plan skip_all => "Test::Perl::Critic is not installed."; }; Test::Perl::Critic->import( -profile => 'xt/perlcriticrc' ); all_critic_ok(qw( ex lib t xt )); perl-MojoX-Renderer-Xslate-0.08/xt/perlcriticrc000064400000000000000000000007331177564666400215310ustar00rootroot00000000000000verbose = 8 [CodeLayout::ProhibitHardTabs] allow_leading_tabs = 0 severity = 5 [CodeLayout::ProhibitTrailingWhitespace] severity = 5 # requires Perl::Critic::More [CodeLayout::RequireASCII] severity = 5 [TestingAndDebugging::RequireUseWarnings] severity = 5 # requires Regexp::Parser [RegularExpressions::ProhibitUnusedCapture] severity = 5 [-TestingAndDebugging::ProhibitNoStrict] [-BuiltinFunctions::ProhibitStringyEval] [-ValuesAndExpressions::ProhibitLeadingZeros] perl-MojoX-Renderer-Xslate-0.08/xt/pod.t000064400000000000000000000002471177564666400200700ustar00rootroot00000000000000use strict; use warnings; use Test::More; eval "use Test::Pod 1.00"; if ($@) { plan skip_all => 'Test::Pod 1.00 required for testing POD'; } all_pod_files_ok(); perl-MojoX-Renderer-Xslate-0.08/xt/pod_coverage.t000064400000000000000000000002701177564666400217370ustar00rootroot00000000000000use strict; use warnings; use Test::More; eval "use Test::Pod::Coverage 1.00; 1" or do { plan skip_all => 'Test::Pod::Coverage 1.00 is not installed.'; }; all_pod_coverage_ok(); perl-MojoX-Renderer-Xslate-0.08/xt/vars.t000064400000000000000000000002431177564666400202550ustar00rootroot00000000000000use strict; use warnings; use Test::More; eval "use Test::Vars; 1" or do { plan skip_all => 'Test::Vars is not installed.'; }; all_vars_ok(); done_testing;