fenom/docs/usage.md

39 lines
774 B
Markdown
Raw Normal View History

2013-06-28 11:53:53 +04:00
Basic usage
===========
### Initialize Fenom
2013-06-28 11:53:53 +04:00
Use factory method
2013-06-28 11:53:53 +04:00
```php
$fenom = Fenom::factory('/path/to/templates', '/path/to/compiled/template', $options);
```
2013-06-28 11:53:53 +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);
```
### Render template
2013-06-28 11:53:53 +04:00
Output template
2013-06-28 11:53:53 +04:00
```php
$fenom->display("template/name.tpl", $vars);
```
Get template into the variable
```php
$result = $fenom->fetch("template/name.tpl", $vars);
```
Create pipe-line into callback
```php
2013-07-04 09:57:07 +04:00
$fenom->pipe(
"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
```