1. Go to this page and download the library: Download codelake/template-flow 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/ */
codelake / template-flow example snippets
use CodeLake\TemplateFlow\TemplatingEngine;
$engine = new TemplatingEngine();
$engine->set_template('Hello {{name}}!');
$engine->set_data(['name' => 'foo']);
$result = $engine->render(); // evaluates to 'Hello foo!'
use CodeLake\TemplateFlow\TemplatingEngine;
$engine = new TemplatingEngine();
$engine->set_template('Hello {{name|capitalize}}!');
$engine->set_data(['name' => 'foo']);
$result = $engine->render(); // evaluates to 'Hello Foo!'
use CodeLake\TemplateFlow\TemplatingEngine;
$engine = new TemplatingEngine();
$engine->set_template('Welcome {{name|shorten(4)}}.');
$engine->set_data(['name' => 'Johnny']);
$result = $engine->render();
// produces 'Welcome John.'
use CodeLake\TemplateFlow\TemplatingEngine;
$engine = new TemplatingEngine();
// use the capitalize pipe to make the first letter upper case
$engine->set_template('Please fill out our {{survey_link|link(Survey)}}!');
$engine->set_data(['survey_link' => 'www.example-survey.com']);
$result = $engine->render();
// produces anchor '<a href="www.example-survey.com">Survey</a>'
use CodeLake\TemplateFlow\TemplatingEngine;
class MyPipes {
/**
* Returns the last character of a string.
*/
static function last(string $value): string {
return substr($value, -1);
}
}
TemplatingEngine::pipes_register_class(MyPipes::class);
// all static methods of the class 'MyPipes' are now available as pipes
use CodeLake\TemplateFlow\TemplatingEngine;
class MyPipes {
/**
* Returns the last character of a string.
*/
static function last(string $value): string {
return substr($value, -1);
}
}
TemplatingEngine::pipes_register_class(MyPipes::class);
// all static methods of the class 'MyPipes' are now available as pipes
TemplatingEngine::pipes_unregister_class(MyPipes::class);
// the pipes are now unavailable for new pipelines
use CodeLake\TemplateFlow\TemplatingEngine;
use CodeLake\TemplateFlow\TemplatePipes;
TemplatingEngine::pipes_register_class(TemplatePipes::class);
use CodeLake\TemplateFlow\TemplatingEngine;
$engine = new TemplatingEngine();
$engine->set_template('Please fill out our {{survey_link|link(Survey)}}!');
$engine->set_data(['survey_link' => 'www.example-survey.com']);
$result = $engine->render();
// produces anchor '<a href="www.example-survey.com">Survey</a>'
use CodeLake\TemplateFlow\TemplatingEngine;
$engine = new TemplatingEngine();
$engine->set_template('If you want, contact our {{support_link|link(Support|mail)}}!');
$engine->set_data(['support_link' => '[email protected]']);
$result = $engine->render();
// produces anchor '<a href="mailto:[email protected]">Support</a>'
use CodeLake\TemplateFlow\TemplatingEngine;
$engine = new TemplatingEngine();
$engine->set_template('Welcome {{name|shorten(4)}}.');
$engine->set_data(['name' => 'Johnny']);
$result = $engine->render();
// produces 'Welcome John.'
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.