MojoX::Template::PHP - PHP processing engine for MojoX::Plugin::PHP
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);
my $encoding = $mt->encoding; $mt = $mt->encoding( $charset );
Encoding used for template files.
my $file = $mt->include_file; $mt = $mt->include_file( $path );
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.
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.
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.
Marty O'Brien <email@example.com>
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.