1. Go to this page and download the library: Download webiny/template-engine library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
webiny / template-engine example snippets
class MyClass
{
use \Webiny\Component\TemplateEngine\TemplateEngineTrait;
function __construct() {
// assing name and id to the template and render it
$this->templateEngine('Smarty')->render('template.tpl', ['name'=>'John', 'id'=>15]);
}
}
namespace MyApp\Demo;
class MySmartyExtension extends \Webiny\Component\TemplateEngine\Drivers\Smarty\SmartyExtension
{
/**
* @overwrite
* @return array
*/
function getModifiers(){
return [
new SmartySimplePlugin('custom_upper', 'modifier', [$this, 'customUpper'])
];
}
/**
* Callback for my custom_upper modifier.
*
* @param $params
*
* @return string
*/
function customUpper($params){
return strtoupper($params);
}
/**
* Returns the name of the plugin.
*
* @return string
*/
function getName() {
return 'my_extension';
}
}
{'this is my name'|custom_upper}
// outputs: THIS IS MY NAME
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.