Closed raxan closed 9 years ago
The filter functions are an array of closures to call.
https://github.com/Xeoncross/PHP-Template/blob/master/Template.php#L130
So you would do something like
<?php
$this->end(
'content',
true,
array('trim', 'strtolower', 'yourfunctionhere', function($buffer) { return 'foo' . $buffer; }, etc.... )
);
?>
Hi
thanks for your reply.
not sure if correctly understand.
Let me repeat, this array of function are all called before output? and receive as param the content of block?
So I can so something like:
<?php $this->end( 'content', true, array(function($buffer) { return strip_tags($buffer); }) ); ?>
which will remove html tags from content?
cool !
can this be used for create like wordpress shortcodes?
Yes, you can make shortcodes. Assuming they look like [yourwordhere]
...
<?php
$this->end(
'content',
true,
array(function($buffer) {
if(preg_match('~\[\(w+)\]~', $buffer, $match)) { print_r($match); }
} )
);
?>
Great! Thanks! I will play with it.
Hi is not mentiond in docs third params "filters" for method end()
end($name, $keep_parent) end a template block and save
how to use it and what is purpose of this ?
Thanks!!