-
Notifications
You must be signed in to change notification settings - Fork 0
Taglets
kastigar edited this page Nov 11, 2010
·
1 revision
Any tag can be extended or created.
###Custom lexical tokens
%img{80x80 for user #123}
<img src="<?php echo $this->thumbUrl('user', 123, 80, 80) ?>" width="80" height="80" />
<?php
namespace My\Yahaml\Node;
class ImgTag extends Yahaml\Node\Tag
{
protected function _processCLT($text)
{
if (!preg_match('~^(\d+)x(\d+) for (\w+) #(\d+)$~', $text, $matches)) {
throw new SyntaxError("Wrong formatted CLT for tag Img");
}
$this->_attrs['width'] = $matches[1];
$this->_attrs['height'] = $matches[2];
$this->_attrs['src'] = "<?php echo $this->thumbUrl('{$matches[3]}', {$matches[4]}, {$matches[1]}, {$matches[2]}) ?>";
}
}
###Custom tags And even more, you can create own virtual taglets
TODO: rewrite above example for thumb taglet...