NAME
Zapp::Util - General utilities for Zapp
VERSION
version 0.005
SUBROUTINES
build_data_from_params
Build a data structure from the parameters in the given request, optionally with the given prefix. Parameter names are paths in the resulting data structure.
# ?name.first=Turanga&name.last=Leela
{ name => { first => 'Turanga', last => 'Leela' } }
# ?crew[0]=Fry&crew[1]=Leela&crew[2]=Zoidberg%20Why%20Not
{ crew => [ 'Fry', 'Leela', 'Zoidberg Why Not' ] }
# ?[0].name=Hubert&[0].age=160&[1].name=Cubert&[1].age=12
[ { name => 'Hubert', age => 160 }, { name => 'Cubert', age => 12 } ]
get_slot_from_data
Get a reference to the given path in the given data. Can be used to set values at paths.
get_path_from_data
Get the value for a given path out of the given data.
get_path_from_schema
Get the schema for a given path out of the given JSON Schema. Will traverse object properties
and array items
to find the schema.
prefix_field
Add a prefix to any field in the given HTML or Mojo::DOM object. Prefixes are added to the name
and id
attributes of any form inputs, and the for
attribute of any labels.
rename_field
Rename any form fields in the given HTML or Mojo::DOM object using the provided mapping. This changes the field name
and id
attributes, and also the corresponding label for
attribute.
parse_zapp_attrs
Parse special data-zapp
attributes in the given HTML or Mojo::DOM object. These attributes add dynamic features to templates for Zapp::Task, Zapp::Type, or Zapp::Trigger.
- data-zapp-if="<expression>"
-
Display this element if the given
<expression>
is true. The expression can contain string literals, data paths, and the following operators:== != > < >= <= eq ne gt lt ge le
If the expression is true, the element is given the
zapp-visible
class and will appear. Expressions are evaluated in Perl when rendering the template and in JavaScript when the user is modifying the form.
ansi_colorize
Apply ANSI coloring and formatting to the given text. This is used to render output from a program that uses ANSI escape sequences.
my $html = ansi_colorize( $stdout );
AUTHOR
Doug Bell <preaction@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2021 by Doug Bell.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 461:
You forgot a '=back' before '=head2'