MojoX::Template::PHP - PHP processing engine for MojoX::Plugin::PHP
0.03
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;
MojoX::Template::PHP is a way to use PHP as a templating system for your Mojolicious application.
MojoX::Template::PHP implements the following attributes:
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.
my $encoding = $mt->encoding; $mt = $mt->encoding( $charset );
Encoding used for template files.
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.
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.php
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.
MojoX::Template::PHP inherits all methods from Mojo::Base, and the following new ones:
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.
my $output = $mt->render($template);
Render a PHP template.
my $output = $mt->render_file( $php_file_path );
Render template file.
MojoX::Plugin::PHP, Mojo::Template, PHP, Catalyst::View::Template::PHP
Marty O'Brien <mob@cpan.org>
Copyright 2013, 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.
To install MojoX::Plugin::PHP, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MojoX::Plugin::PHP
CPAN shell
perl -MCPAN -e shell install MojoX::Plugin::PHP
For more information on module installation, please visit the detailed CPAN module installation guide.