Доброго всем
¡ ¡ ¡ ALL GLORY TO GLORIA ! ! !
DBIx::Mojo::Template - Render SQL statements templates by Mojo::Template
0.05
use DBIx::Mojo::Template; my $dict = DBIx::Mojo::Template->new(__PACKAGE__,mt=>{tag_start=>'%{', tag_end=>'%}',}); my $sql = $dict->{'foo'}->render(table=>'foo', where=> 'where id=?'); __DATA__ @@ foo?cache=1 %# my foo statement with prepare_cached (model sth) select * from {% $table %} {% $where %}
my $dict = DBIx::Mojo::Template->new('Foo::Bar', vars=>{...}, mt=>{...})
where arguments:
$pkg (string)
Package name, where __DATA__ section SQL dictionary. Package must be loaded (use/require) before!
vars (hashref)
Hashref of this dict templates variables. Vars can be merged when render - see #render.
mt (hashref)
For Mojo::Template object attributes. See Mojo::Template#ATTRIBUTES.
mt=>{ line_start=>'+', }
Defaults attrs:
mt=> {vars => 1, prepend=>'no strict qw(vars); no warnings qw(uninitialized);',}
Merge ditcs packages to one. Arguments same as #new.
DBIx::Mojo::Template->singleton('Foo'); my $dict = DBIx::Mojo::Template->singleton('Bar');
Render template dict key.
my $sql = $dict->render($key, var1=>..., var2 => ...,);
Each dict item is a object DBIx::Mojo::Statement with one method render:
render
my $sql = $dict->{'key foo'}->render(bar=>'baz', ...);
Same as #new but returns unblessed hashref dict.
Михаил Че (Mikhail Che), <mche[-at-]cpan.org>
<mche[-at-]cpan.org>
Please report any bugs or feature requests at https://github.com/mche/DBIx-Mojo-Template/issues. Pull requests also welcome.
Copyright 2016 Михаил Че (Mikhail Che).
This module is free software; you can redistribute it and/or modify it under the term of the Perl itself.
To install DBIx::Mojo::Template, copy and paste the appropriate command in to your terminal.
cpanm
cpanm DBIx::Mojo::Template
CPAN shell
perl -MCPAN -e shell install DBIx::Mojo::Template
For more information on module installation, please visit the detailed CPAN module installation guide.