The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Mojolicious::Component - Module-based Template Class

ABSTRACT

Module-based Template Base Class

SYNOPSIS

  package App::Component::Image;

  use Mojo::Base 'Mojolicious::Component';

  has alt => 'random';
  has height => 126;
  has width => 145;
  has src => '/random.gif';

  package main;

  my $component = App::Component::Image->new;

  # $component->render

DESCRIPTION

This package provides an abstract base class for rendering derived component-based template (partials) classes.

ATTRIBUTES

This package has the following attributes:

controller

  controller(InstanceOf["Mojolicious::Controller"])

This attribute is read-only, accepts (InstanceOf["Mojolicious::Controller"]) values, and is optional.

space

  space(InstanceOf["Data::Object::Space"])

This attribute is read-only, accepts (InstanceOf["Data::Object::Space"]) values, and is optional.

template

  template(InstanceOf["Mojo::Template"])

This attribute is read-only, accepts (InstanceOf["Mojo::Template"]) values, and is optional.

METHODS

This package implements the following methods:

render

  render(Any %args) : Str

The render method loads the component template string data from the DATA section of the component class and renders it using the Mojo::Template object available via "template".

render example #1
  # given: synopsis

  my $rendered = $component->render;
render example #2
  # given: synopsis

  my $rendered = $component->render(
    readonly => 1,
  );

AUTHOR

Al Newkirk, awncorp@cpan.org

LICENSE

Copyright (C) 2011-2019, Al Newkirk, et al.

This is free software; you can redistribute it and/or modify it under the terms of the The Apache License, Version 2.0, as elucidated in the "license file".

PROJECT

Wiki

Project

Initiatives

Milestones

Contributing

Issues