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
|
|
|
|
2013-07-02 11:07:33 +04:00
|
|
|
Use 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
|
|
|
|
2013-07-02 11:07:33 +04:00
|
|
|
Use `new` operator
|
|
|
|
```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);
|
|
|
|
```
|
|
|
|
|
2013-07-02 11:07:33 +04:00
|
|
|
### Render 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
|
|
|
```
|
|
|
|
|
|
|
|
Get template into the variable
|
|
|
|
```php
|
|
|
|
$result = $fenom->fetch("template/name.tpl", $vars);
|
|
|
|
```
|
|
|
|
|
|
|
|
Create pipe-line into callback
|
|
|
|
```php
|
|
|
|
$fenom->export(
|
|
|
|
"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-06-28 11:53:53 +04:00
|
|
|
```
|