use Carp;
use English qw< -no_match_vars >;
use JSON::PP qw< decode_json >;
use Scalar::Util qw< blessed >;
use Data::Resolver
my $ar = ref($auto);
if ($ar eq '' && $auto =~ m{\A [\[\{]}mxs) {
$auto = decode_json($auto);
$ar = ref($auto);
}
return collage_from_definition($auto)
ak 'no useful input';
} ## end sub collage
sub collage_from_definition ($def) {
$def = decode_json($def) unless ref $def;
$def = {commands => $def} if ref($def) eq 'ARRAY';
return PDF::Colla
to assemble the target PDF.
=back
The definitions are supposed to be JSON file matching keys
C<\A(?:\./)?definitions/(.*)\.json\z>. The part in the capture group is
one of the available L</selectors
TemplatesCollection;
use v5.24;
use warnings;
{ our $VERSION = '0.003' }
use Carp;
use JSON::PP qw< decode_json >;
use Scalar::Util qw< blessed >;
use PDF::Collage::Template ();
use Moo;
use experim
s => 'lazy');
sub _build__selectors ($self) {
my @selectors =
map { s{\.json}{}rmxs }
grep { m{\.json \z}mxs }
$self->resolver->get_sub_resolver('definitions')->list_asset_keys;
er('definitions')
# ->get_asset("$selector.json")->parsed_as_json;
my $def = $resolver->get_asset("./definitions/$selector.json")->parsed_as_json;
$def = { commands => $def } unless ref($d
t it should support:
definitions/bar.json
definitions/foo.json
definitions/galook.json
existing-file.pdf
logo.png
Every key ending with C<.json> and starting with C<definitions/>,
opt
ition);
my $pc = collage(definition => \@array_definition);
my $pc = collage(definition => $json_hash_or_array);
This is a I<Do What I Mean> catchall function to generate an instance of
either
tion>.
If the definition is a string starting with either C<{> or C<[>, it is
considered a valid JSON string and decoded as such, then processed as
follows.
If the definition is an array reference,