2013-06-28 11:53:53 +04:00
|
|
|
Basic usage
|
|
|
|
===========
|
|
|
|
|
2013-07-02 11:07:33 +04:00
|
|
|
### Initialize Fenom
|
2013-06-28 11:53:53 +04:00
|
|
|
|
2014-02-07 23:44:03 +04:00
|
|
|
Creating an object via factory method
|
2013-06-28 11:53:53 +04:00
|
|
|
```php
|
2013-07-02 11:07:33 +04:00
|
|
|
$fenom = Fenom::factory('/path/to/templates', '/path/to/compiled/template', $options);
|
|
|
|
```
|
2013-06-28 11:53:53 +04:00
|
|
|
|
2014-02-07 23:44:03 +04:00
|
|
|
Creating an object via `new` operator
|
2013-07-02 11:07:33 +04:00
|
|
|
```php
|
|
|
|
$fenom = new Fenom(new Provider('/path/to/templates'));
|
2013-06-28 11:53:53 +04:00
|
|
|
$fenom->setCompileDir('/path/to/template/cache');
|
|
|
|
$fenom->setOptions($options);
|
|
|
|
```
|
|
|
|
|
2014-02-07 23:44:03 +04:00
|
|
|
### Rendering template
|
2013-06-28 11:53:53 +04:00
|
|
|
|
2013-07-02 11:07:33 +04:00
|
|
|
Output template
|
2013-06-28 11:53:53 +04:00
|
|
|
```php
|
|
|
|
$fenom->display("template/name.tpl", $vars);
|
2013-07-02 11:07:33 +04:00
|
|
|
```
|
|
|
|
|
2014-02-07 23:44:03 +04:00
|
|
|
Get the result of rendering the template
|
2013-07-02 11:07:33 +04:00
|
|
|
```php
|
|
|
|
$result = $fenom->fetch("template/name.tpl", $vars);
|
|
|
|
```
|
|
|
|
|
2014-02-07 23:44:03 +04:00
|
|
|
Create the pipeline of rendering into callback
|
2013-07-02 11:07:33 +04:00
|
|
|
```php
|
2013-07-04 09:57:07 +04:00
|
|
|
$fenom->pipe(
|
2013-07-02 11:07:33 +04:00
|
|
|
"template/sitemap.tpl",
|
|
|
|
$vars,
|
|
|
|
$callback = [new SplFileObject("/tmp/sitemap.xml", "w"), "fwrite"], // pipe to file /tmp/sitemap.xml
|
|
|
|
$chunk_size = 1e6 // chunk size for callback
|
|
|
|
);
|
2013-07-04 09:57:07 +04:00
|
|
|
```
|