Template-Plugin-YAML-1.23/0002755000175000017500000000000011121504621015321 5ustar richardcrichardcTemplate-Plugin-YAML-1.23/MANIFEST0000644000175000017500000000012611121440440016445 0ustar richardcrichardcREADME Changes Makefile.PL MANIFEST META.yml lib/Template/Plugin/YAML.pm t/00simple.t Template-Plugin-YAML-1.23/t/0002755000175000017500000000000011121504621015564 5ustar richardcrichardcTemplate-Plugin-YAML-1.23/t/00simple.t0000644000175000017500000000062311121440440017377 0ustar richardcrichardc#!perl -w use strict; use Test::More tests => 3; use Template; use YAML; my $tt = new Template; my $out; my $data = [ { foo => 'bar' }, { foo => 'baz' } ]; ok( $tt->process( \"[% USE YAML %][% YAML.dump( struct ) %]", { struct => $data, }, \$out ), "TT ran" ); ok( !$tt->error, " without error" ); is_deeply( YAML::Load($out), $data, "YAML round tripped to original data" ); Template-Plugin-YAML-1.23/lib/0002755000175000017500000000000011121504621016067 5ustar richardcrichardcTemplate-Plugin-YAML-1.23/lib/Template/0002755000175000017500000000000011121504621017642 5ustar richardcrichardcTemplate-Plugin-YAML-1.23/lib/Template/Plugin/0002755000175000017500000000000011121504621021100 5ustar richardcrichardcTemplate-Plugin-YAML-1.23/lib/Template/Plugin/YAML.pm0000644000175000017500000000550011121504614022200 0ustar richardcrichardcuse strict; package Template::Plugin::YAML; use Template::Plugin; use base 'Template::Plugin'; use YAML qw(Dump Load DumpFile LoadFile); use vars qw($VERSION); $VERSION = '1.23'; =head1 NAME Template::Plugin::YAML - Plugin interface to YAML =head1 SYNOPSIS [% USE YAML %] [% YAML.dump(variable) %] [% YAML.dump_html(variable) %] [% value = YAML.undump(yaml_string) %] [% YAML.dumpfile(filename, variable) %] [% value = YAML.undumpfile(filename) %] =head1 DESCRIPTION This is a simple Template Toolkit Plugin Interface to the YAML module. A YAML object will be instantiated via the following directive: [% USE YAML %] As a standard plugin, you can also specify its name in lower case: [% USE yaml %] =head1 METHODS These are the methods supported by the YAML object. =head2 dump( @variables ) Generates a raw text dump of the data structure(s) passed [% USE Dumper %] [% yaml.dump(myvar) %] [% yaml.dump(myvar, yourvar) %] =cut sub dump { my $self = shift; my $content = Dump @_; return $content; } =head2 dump_html( @variables ) Generates a dump of the data structures, as per C, but with the characters E, E and E converted to their equivalent HTML entities, spaces converted to   and newlines converted to EbrE. [% USE yaml %] [% yaml.dump_html(myvar) %] =cut sub dump_html { my $self = shift; my $content = Dump @_; for ($content) { s/&/&/g; s/ / /g; s//>/g; s/\n/
\n/g; } return $content; } =head2 undump( $string ) Converts a YAML-encoded string into the equivalent data structure. Here's a way to deep-copy a complex structure by completely serializing the data. [% USE yaml; yaml_string = yaml.dump(complex_data_structure); complex_copy = yaml.undump(yaml_string); %] =cut sub undump { my $self = shift; return Load shift; } =head2 dumpfile( $file, @variables ) Converts the data to YAML encoding, and dumps it to the specified filepath. [% USE yaml; yaml.dumpfile(".storage", my_data) %] =cut sub dumpfile { my $self = shift; return DumpFile @_; } =head2 undumpfile( $file ) Loads the YAML-encoded data from the specified filepath [% USE yaml; my_data = yaml.undumpfile(".storage") %] =cut sub undumpfile { my $self = shift; return LoadFile @_; } 1; __END__ =head1 AUTHORS Richard Clamp , with undump, undumpfile, and dumpfile implementation by Randal L. Schwartz based on Simon Matthews' L =head1 COPYRIGHT Copyright 2003, 2008 Richard Clamp All Rights Reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO L =cut Template-Plugin-YAML-1.23/META.yml0000644000175000017500000000066311121504621016575 0ustar richardcrichardc# http://module-build.sourceforge.net/META-spec.html #XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX# name: Template-Plugin-YAML version: 1.23 version_from: lib/Template/Plugin/YAML.pm installdirs: site requires: Template: 0 Test::More: 0 YAML: 0 distribution_type: module generated_by: ExtUtils::MakeMaker version 6.17 Template-Plugin-YAML-1.23/Changes0000644000175000017500000000042311121504551016613 0ustar richardcrichardc1.23 15th December, 2008 Fix the tests so we don't rely on golden output. Should fix most of the failing smoke cases. 1.22 29th August, 2003 Adds undump, dumpfile, undumpfile as provided by Randal L. Schwartz 1.21 30th July, 2003 Initial CPAN release Template-Plugin-YAML-1.23/Makefile.PL0000644000175000017500000000037711121477103017304 0ustar richardcrichardcuse ExtUtils::MakeMaker; WriteMakefile( 'NAME' => 'Template::Plugin::YAML', 'VERSION_FROM' => 'lib/Template/Plugin/YAML.pm', 'PREREQ_PM' => { 'Test::More' => 0, 'Template' => 0, 'YAML' => 0, } ); Template-Plugin-YAML-1.23/README0000644000175000017500000000231611121504572016206 0ustar richardcrichardcREADME for Template::Plugin::YAML =head1 NAME Template::Plugin::YAML - Plugin interface to YAML =head1 SYNOPSIS [% USE YAML %] [% YAML.dump(variable) %] [% YAML.dump_html(variable) %] [% value = YAML.undump(yaml_string) %] [% YAML.dumpfile(filename, variable) %] [% value = YAML.undumpfile(filename) %] =head1 INSTALLATION perl Makefile.PL make test and if all goes well make install =head1 HISTORY What changed over the last 3 revisions =over =item 1.23 15th December, 2008 Fix the tests so we don't rely on golden output. Should fix most of the failing smoke cases. =item 1.22 29th August, 2003 Adds undump, dumpfile, undumpfile as provided by Randal L. Schwartz =item 1.21 30th July, 2003 Initial CPAN release =back =head1 AUTHORS Richard Clamp , with undump, undumpfile, and dumpfile implementation by Randal L. Schwartz based on Simon Matthews' L =head1 COPYRIGHT Copyright 2003, 2008 Richard Clamp All Rights Reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO L