view release on metacpan or search on metacpan
lib/Catmandu/Exporter/Template.pm view on Meta::CPAN
package Catmandu::Exporter::Template;
use Catmandu::Sane;
use Catmandu::Util qw(is_string);
use Catmandu;
use Template;
lib/Catmandu/Exporter/Template.pm view on Meta::CPAN
$self->_process($self->template_after) if $self->template_after;
}
=head1 NAME
Catmandu::Exporter::Template - a TT2 Template exporter in Catmandu style
=head1 SYNOPSIS
# From the command line
echo '{"colors":["red","green","blue"]}' |
lib/Catmandu/Exporter/Template.pm view on Meta::CPAN
<color>[% c %]</color>
[% END %]
</colors>
# From perl
use Catmandu::Exporter::Template;
my $exporter = Catmandu::Exporter::Template->new(
fix => 'myfix.txt'
xml => 1,
template_before => '<path>/header.xml' ,
template => '<path>/record.xml' ,
template_after => '<path>/footer.xml' ,
view all matches for this distribution
view release on metacpan or search on metacpan
0.8009 2014-03-07
- sort_field fix
- fix undefined lib_path
0.8008 2014-03-05
- split off Catmandu::Exporter::Template
0.8007 2014-03-04
- rewrite Catmandu::Serializer
- split off Catmandu::Serializer::storable
- split off Catmandu::Serializer::messagepack
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Dancer/Plugin/Catmandu/OAI.pm view on Meta::CPAN
use Catmandu::Sane;
use Catmandu::Util qw(is_string is_array_ref hash_merge);
use Catmandu;
use Catmandu::Fix;
use Catmandu::Exporter::Template;
use Data::MessagePack;
use MIME::Base64 qw(encode_base64url decode_base64url);
use Dancer::Plugin;
use Dancer qw(:syntax);
use DateTime;
lib/Dancer/Plugin/Catmandu/OAI.pm view on Meta::CPAN
my $render = sub {
my ($tmpl, $data) = @_;
content_type 'xml';
my $out = "";
my $exporter = Catmandu::Exporter::Template->new(
template => $tmpl,
file => \$out
);
$exporter->add($data);
$exporter->commit;
lib/Dancer/Plugin/Catmandu/OAI.pm view on Meta::CPAN
$vars->{datestamp} = $format_datestamp->(
$rec->{$setting->{datestamp_field}});
$vars->{deleted} = $sub_deleted->($rec);
$vars->{setSpec} = $sub_set_specs_for->($rec);
my $metadata = "";
my $exporter = Catmandu::Exporter::Template->new(
%$template_options,
template => $format->{template},
file => \$metadata,
);
if ($format->{fix}) {
lib/Dancer/Plugin/Catmandu/OAI.pm view on Meta::CPAN
deleted => $deleted,
setSpec => $sub_set_specs_for->($rec),
};
unless ($deleted) {
my $metadata = "";
my $exporter = Catmandu::Exporter::Template->new(
%$template_options,
template => $format->{template},
file => \$metadata,
);
if ($format->{fix}) {
lib/Dancer/Plugin/Catmandu/OAI.pm view on Meta::CPAN
* setSpec - A short string for the same of the set
* setName - A longer description of the set
* setDescription - an optional and repeatable container that may hold community-specific XML-encoded data about the set. Should be string or array of strings.
* cql - The CQL command to find records in this set in the L<Catmandu::Store>
* xsl_stylesheet - Optional path to an xsl stylesheet
* template_options - An optional hash of configuration options that will be passed to L<Catmandu::Exporter::Template> or L<Template>.
Below is a sample minimal configuration for the 'sample.yml' demo above:
$ cat config.yml
charset: "UTF-8"
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Dancer/Plugin/Catmandu/SRU.pm view on Meta::CPAN
our $VERSION = '0.0504';
use Catmandu::Sane;
use Catmandu;
use Catmandu::Fix;
use Catmandu::Exporter::Template;
use Catmandu::Util qw(hash_merge);
use SRU::Request;
use SRU::Response;
use Dancer qw(:syntax);
use Dancer::Plugin;
lib/Dancer/Plugin/Catmandu/SRU.pm view on Meta::CPAN
};
$hits->each(sub {
my $data = $_[0];
my $metadata = "";
my $exporter = Catmandu::Exporter::Template->new(
%$template_options,
template => $template,
file => \$metadata
);
$exporter->add($fix ? $fix->fix($data) : $data);
lib/Dancer/Plugin/Catmandu/SRU.pm view on Meta::CPAN
* record_schemas - An array of all supported record schemas
* identifier - The SRU identifier for the schema (see L<http://www.loc.gov/standards/sru/recordSchemas/>)
* name - A short descriptive name for the schema
* fix - Optionally an array of fixes to apply to the records before they are transformed into XML
* template - The path to a Template Toolkit file to transform your records into this format
* template_options - An optional hash of configuration options that will be passed to L<Catmandu::Exporter::Template> or L<Template>
* content_type - Set a custom content type header, the default is 'text/xml'.
Below is a sample minimal configuration for the 'sample.yml' demo above:
charset: "UTF-8"
view all matches for this distribution
view release on metacpan or search on metacpan
Notes/cpan-namespaces/cpan-namespaces-L1-L3.txt view on Meta::CPAN
Catmandu::Exporter::RDF
Catmandu::Exporter::RIS
Catmandu::Exporter::Stat
Catmandu::Exporter::TSV
Catmandu::Exporter::Table
Catmandu::Exporter::Template
Catmandu::Exporter::Text
Catmandu::Exporter::XLS
Catmandu::Exporter::XLSX
Catmandu::Exporter::XML
Catmandu::Exporter::XSD
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Plack/App/Catmandu/OAI.pm view on Meta::CPAN
use Catmandu;
use Moo;
use Types::Standard qw(Str ArrayRef HashRef Enum Int CodeRef ScalarRef);
use Types::Common::String qw(NonEmptyStr);
use Types::Common::Numeric qw(PositiveInt);
use Catmandu::Exporter::Template;
use Catmandu::Fix;
use Data::MessagePack;
use MIME::Base64 qw(encode_base64url decode_base64url);
use DateTime;
use DateTime::Format::ISO8601;
lib/Plack/App/Catmandu/OAI.pm view on Meta::CPAN
}
sub _tt_process ($self, $tmpl, $data) {
my $out = "";
open my $fh, '>:utf8', \$out;
my $exporter = Catmandu::Exporter::Template->new(
template => $tmpl,
fh => $fh,
);
$exporter->add($data);
$exporter->commit;
lib/Plack/App/Catmandu/OAI.pm view on Meta::CPAN
$vars->{id} = $id;
$vars->{datestamp} = $self->_datestamp_formatter->($rec->{$self->datestamp_field()});
$vars->{deleted} = $self->deleted->($rec);
$vars->{setSpec} = $self->set_specs_for->($rec);
my $metadata = "";
my $exporter = Catmandu::Exporter::Template->new(
%{$self->template_options},
template => $format->{template},
file => \$metadata,
);
if ($format->{fix}) {
lib/Plack/App/Catmandu/OAI.pm view on Meta::CPAN
deleted => $deleted,
setSpec => $self->set_specs_for->($rec),
};
unless ($deleted) {
my $metadata = "";
my $exporter = Catmandu::Exporter::Template->new(
%{$self->template_options},
template => $format->{template},
file => \$metadata,
);
if ($format->{fix}) {
lib/Plack/App/Catmandu/OAI.pm view on Meta::CPAN
Required: true
=item template_options
An optional hash of configuration options that will be passed to L<Catmandu::Exporter::Template> or L<Template>
=back
As this is meant as a drop in replacement for L<Dancer::Plugin::Catmandu::OAI> all arguments should be the same.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Plack/App/Catmandu/SRU.pm view on Meta::CPAN
our $VERSION = '0.02';
use Catmandu::Sane;
use Catmandu;
use Catmandu::Fix;
use Catmandu::Exporter::Template;
use URI;
use SRU::Request;
use SRU::Response;
use Types::Standard qw(Str ArrayRef HashRef ConsumerOf);
use Types::Common::String qw(NonEmptyStr);
lib/Plack/App/Catmandu/SRU.pm view on Meta::CPAN
};
$hits->each(sub {
my $data = $_[0];
my $metadata = "";
my $exporter = Catmandu::Exporter::Template->new(
%$template_options,
template => $template,
file => \$metadata
);
$exporter->add($fix ? $fix->fix($data) : $data);
lib/Plack/App/Catmandu/SRU.pm view on Meta::CPAN
* template - The path to a Template Toolkit file to transform your records into this format
=item template_options
An optional hash of configuration options that will be passed to L<Catmandu::Exporter::Template> or L<Template>
=item content_type
Set a custom content type header, the default is C<text/xml>.
view all matches for this distribution