Доброго всем
DBIx::POS::Template
¡ ¡ ¡ ALL GLORY TO GLORIA ! ! !
VERSION
0.00003
NAME
DBIx::POS::Template - is a fork of DBIx::POS. Define a dictionary of SQL statements in a POD dialect (POS) plus expand template sql with embedded Perl by Text::Template.
SYNOPSIS
use DBIx::POS::Template;
# separate object
my $pos = DBIx::POS::Template->new(__FILE__, enc=>'utf8');
# or singleton DBIx::POS::Template->instance($file, ...);
my $sql = $pos->{test1}->template(where => "bar = ?");
# or $pos->template('test1', where => "bar = ?")
=pod
=name test1
=desc test the DBIx::POS::Template module
=param
Some arbitrary parameter
=sql
select * from foo
where {% $where %}
;
=cut
DESCRIPTION
DBIx::POS::Template is subclass Pod::Parser to define a POD dialect for writing a SQL dictionary(s) with templating.
By separating the SQL code from its normal context of execution, it encourages you to do other things with it---for instance, it is easy to create a script that can do performance testing of certain SQL statements in isolation, or to create generic command-line wrapper around your SQL statements.
By giving a framework for documenting the SQL, it encourages documentation of the intent and/or implementation of the SQL code. It also provides all of that information in a format from which other documentation could be generated---say, a chunk of DocBook for incorporation into a guide to programming the application.
This class whould work as separate objects per pod-file or as singleton for all processed files with one dictionary of them.
METHODS
new($file, <options>)
Create separate object and process $file POS with options:
enc (STRING)
Encoding of POD content file.
tt (HASHREF)
Some options will passing to Text::Template->new() for each parsed statement. By default only defined option
DELIMITERS => ['{%', '%}'],
instance($file, <options>)
Return singleton dictionary object, parsed $file keys will collapse/override with previous files. Same options as new
, tt option merge with previous options of instance invokes.
template($key, var1 => ..., var2 => ...)
Fill in dictionary sql with variables by Text::Template#HASH. Other syntax:
$pos->{$key}->template(var1 => ..., var2 => ...)
SEE ALSO
AUTHOR
Михаил Че (Mikhail Che), <mche[-at-]cpan.org>
BUGS / CONTRIBUTING
Please report any bugs or feature requests at https://github.com/mche/DBIx-POS-Template/issues. Pull requests also welcome.
COPYRIGHT
Copyright 2016 Mikhail Che.
This module is free software; you can redistribute it and/or modify it under the term of the Perl itself.