NAME
MojoX::Template::PHP - PHP processing engine for MojoX::Plugin::PHP
VERSION
0.04
SYNOPSIS
use MojoX::Template::PHP;
my $mt = MojoX::Template::PHP->new;
my $output = $mt->render(<<'EOF');
<html>
<head><title>Simple</title><head>
<body>Time:
<?php echo time(); ?>
</body>
</html>
EOF
say $output;
my $output = $mt->render_file( '/path/to/some/template.php' );
say $output;
DESCRIPTION
MojoX::Template::PHP is a way to use PHP as a templating system for your Mojolicious application.
- 1. You can put a Mojolicious wrapper around some decent PHP application (say, WordPress)
- 2. You are on a development project with Perl and PHP programmers, and you want to use Mojolicious as a backend without scaring the PHP developers.
ATTRIBUTES
MojoX::Template::PHP implements the following attributes:
code
my $code = $mt->code;
$mt = $mt->code($code);
Inline PHP code for template. The "interpret" method will check the "include_file" attribute first, and then this attribute to decide what to pass to the PHP interpreter.
encoding
my $encoding = $mt->encoding;
$mt = $mt->encoding( $charset );
Encoding used for template files.
include_file
my $file = $mt->include_file;
$mt = $mt->include_file( $path );
PHP template file to be interpreted. The "interpret" method will check this attribute, and then the "code" attribute to decide what to pass to the PHP interpreter.
name
my $name = $mt->name;
$mt = $mt->name('foo.php');
Name of the template currently being processed. Defaults to template.php
. This value should not contain quotes or newline characters, or error messages might end up being wrong.
template
my $template = $mt->template;
$mt = $mt->template( $template_name );
Should contain the name of the template currently being processed, but I don't think it is ever set to anything now. This value will appear in exception messages.
METHODS
MojoX::Template::PHP inherits all methods from Mojo::Base, and the following new ones:
interpret
my $output = $mt->interpret($c)
Interpret template code. Starts the PHP engine and evaluates the template code with it. See "MojoX::Plugin::PHP" in "CONFIG" for information about various callbacks that can be used to change and extend the behavior of the PHP templating engine.
render
my $output = $mt->render($template);
Render a PHP template.
render_file
my $output = $mt->render_file( $php_file_path );
Render template file.
SEE ALSO
MojoX::Plugin::PHP, Mojo::Template, PHP, Catalyst::View::Template::PHP
AUTHOR
Marty O'Brien <mob@cpan.org>
COPYRIGHT
Copyright 2013-2015, Marty O'Brien. All rights reserved.
This library is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Sortware Foundation; or the Artistic License.
See http://dev.perl.org/licenses for more information.