SEARCH
NEW RPMS
DIRECTORIES
ABOUT
FAQ
VARIOUS
BLOG

 
 

perl-Template-Lace rpm build for : OpenSuSE. For other distributions click perl-Template-Lace.

Name : perl-Template-Lace
Version : 0.017 Vendor : obs://build_opensuse_org/devel:languages:perl
Release : lp156.71.1 Date : 2024-07-03 19:06:27
Group : Development/Libraries/Perl Source RPM : perl-Template-Lace-0.017-lp156.71.1.src.rpm
Size : 0.20 MB
Packager : https://www_suse_com/
Summary : Logic-less, strongly typed, and componentized HTML templates
Description :
Template::Lace is a toolkit that makes it possible to bind HTML templates
to plain old Perl classes as long as they provide a defined interface.
These templates are fully HTML markup only; they contain no display logic,
only valid HTML and component declarations. We use Template::Lace::DOM
(which is a subclass of Mojo::DOM58) to alter the template for presentation
at request time. Template::Lace::DOM provides an API to transform the
template into HTML using instance data and methods provided by the class.
See the class Template::Lace::DOM and Mojo::DOM58 for more about how these
classes allow you to inspect and modify a DOM.

When you have a Perl class that conform to these requirements we call that
a \'Model\' class Here\'s an example of a very simple Model class:

package MyApp::Template::User;

use Moo;

has [qw/age name motto/] => (is=>\'ro\', required=>1);

sub template { q[
< html>
< head>
< title>User Info< /title>
< /head>
< body>
< dl id=\'user\'>
< dt>Name< /dt>
< dd id=\'name\'> -NAME- < /dd>
< dt>Age< /dt>
< dd id=\'age\'> -AGE- < /dd>
< dt>Motto< /dt>
< dd id=\'motto\'> -MOTTO- < /dd>
< /dl>
< /body>
< /html>
]}

sub process_dom {
my ($self, $dom) = AATT_;
$dom->dl(\'#user\', +{
age=>$self->age,
name=>$self->name,
motto=>$self->motto});
}

1;

In this example the Model class defines two methods, \'process_dom\' and
\'template\'. Any Perl class can be used as Model class as long as it
provides these methods (as well as a stub for \'prepare_dom\' which will we
discuss later). The \'template\' method just needs to return a string. It
should contain your desired HTML markup. The \'process_dom\' method is an
instance method on your class, and it gets both \'$self\' and \'$dom\', where
\'$dom\' is a DOM representation of your template (via Template::Lace::DOM).
Anything you want to change about the template should be done via the
Template::Lace::DOM API. This is a subclass of Mojo::DOM58 a Jquery like
API for transforming HTML. Our custom subclass contains some additional
helper methods to make common types of transforms easier. For example here
we use the custom helper \'dl\' to find a \'dl\' tag by its id and then
populate its data by matching hash keys to tag ids.

So how do you get a rendered template out of a Model class? That\'s the job
of two additional classes, Template::Lace::Factory and
Template::Lace::Renderer (with a tag team by Template::Lace::Components
should your template contain components; to be discussed later).

Template::Lace::Factory wraps your model class and inspects it to create an
initial DOM representation of the template (as well as prepare a component
hierarchy, should you have components). Most simply it looks like this:

my $factory = Template::Lace::Factory->new(
model_class=>\'MyApp::Template::User\');

Next you call the \'create\' method on the \'$factory\' instance with the
initial arguments you want to pass to the Model. Create doesn\'t return the
Model directly, but instead returns an instance of Template::Lace::Renderer
which is wrapping the model:

my $renderer = $factory->create(
age=>42,
name=>\'John\',
motto=>\'Life in the Fast Lane!\');

$renderer->model; # this is the actual instance of MyApp::Template::User via


Those initial arguments are passed to the model and used to create an
instance of the model. But the wrapping \'$renderer\' exposes methods that
are used to do the actual transformation. For example

print $renderer->render;

Would return:

< html>
< head>
< title>
User Info
< /title>
< /head>
< body id=\"body\">
< dl id=\"user\">
< dt>
Name
< /dt>
< dd id=\"name\">
John
< /dd>
< dt>
Age
< /dt>
< dd id=\"age\">
42
< /dd>
< dt>
Motto
< /dt>
< dd id=\"motto\">
Why Not?
< /dd>
< /dl>
< /body>
< /html>

And that is the basics of it! Once you have a \'$factory\' you can call
\'create\' on it as many times as you like to make different versions of the
rendered page.

RPM found in directory: /packages/linux-pbone/ftp5.gwdg.de/pub/opensuse/repositories/devel:/languages:/perl:/CPAN-T/15.6/noarch

Content of RPM  Provides Requires

Download
ftp.icm.edu.pl  perl-Template-Lace-0.017-lp156.71.1.noarch.rpm
     

Provides :
perl(Template::Lace)
perl(Template::Lace::ComponentCallback)
perl(Template::Lace::Components)
perl(Template::Lace::DOM)
perl(Template::Lace::Factory)
perl(Template::Lace::Factory::InferInitArgsRole)
perl(Template::Lace::Model::AutoTemplate)
perl(Template::Lace::Model::HasChildren)
perl(Template::Lace::Renderer)
perl(Template::Lace::Utils)
perl-Template-Lace

Requires :
perl(:MODULE_COMPAT_5.26.1)
perl(JSON::MaybeXS)
perl(Module::Runtime)
perl(Mojo::DOM58) >= 1.003
perl(Moo) >= 2.003000
perl(Template::Tiny) >= 1.12
perl(UUID::Tiny)
rpmlib(CompressedFileNames) <= 3.0.4-1
rpmlib(FileDigests) <= 4.6.0-1
rpmlib(PayloadFilesHavePrefix) <= 4.0-1
rpmlib(PayloadIsXz) <= 5.2-1


Content of RPM :
/usr/lib/perl5/vendor_perl/5.26.1/Template
/usr/lib/perl5/vendor_perl/5.26.1/Template/Lace
/usr/lib/perl5/vendor_perl/5.26.1/Template/Lace.pm
/usr/lib/perl5/vendor_perl/5.26.1/Template/Lace/ComponentCallback.pm
/usr/lib/perl5/vendor_perl/5.26.1/Template/Lace/Components.pm
/usr/lib/perl5/vendor_perl/5.26.1/Template/Lace/DOM.pm
/usr/lib/perl5/vendor_perl/5.26.1/Template/Lace/Factory
/usr/lib/perl5/vendor_perl/5.26.1/Template/Lace/Factory.pm
/usr/lib/perl5/vendor_perl/5.26.1/Template/Lace/Factory/InferInitArgsRole.pm
/usr/lib/perl5/vendor_perl/5.26.1/Template/Lace/Model
/usr/lib/perl5/vendor_perl/5.26.1/Template/Lace/Model/AutoTemplate.pm
/usr/lib/perl5/vendor_perl/5.26.1/Template/Lace/Model/HasChildren.pm
/usr/lib/perl5/vendor_perl/5.26.1/Template/Lace/Renderer.pm
/usr/lib/perl5/vendor_perl/5.26.1/Template/Lace/Utils.pm
/usr/lib/perl5/vendor_perl/5.26.1/x86_64-linux-thread-multi
/usr/share/doc/packages/perl-Template-Lace
/usr/share/doc/packages/perl-Template-Lace/Changes
/usr/share/doc/packages/perl-Template-Lace/README
/usr/share/doc/packages/perl-Template-Lace/README.mkdn
/usr/share/doc/packages/perl-Template-Lace/TODO
/usr/share/doc/packages/perl-Template-Lace/examples
/usr/share/doc/packages/perl-Template-Lace/examples/Components
/usr/share/doc/packages/perl-Template-Lace/examples/Components/Master.pm
/usr/share/doc/packages/perl-Template-Lace/examples/Components/TodoList.pm
/usr/share/doc/packages/perl-Template-Lace/examples/TodoListApp.pm
/usr/share/doc/packages/perl-Template-Lace/examples/TodoListPage.pm
/usr/share/licenses/perl-Template-Lace
/usr/share/licenses/perl-Template-Lace/LICENSE
/usr/share/man/man3/Template::Lace.3pm.gz
/usr/share/man/man3/Template::Lace::ComponentCallback.3pm.gz
There is 8 files more in these RPM.

 
ICM