Zend_Markup Renderers
Zend_Markup is currently shipped with one renderer, the
HTML renderer.
Adding your own tags
By adding your own tags, you can add your own functionality to the
Zend_Markup renderers. With the tag structure, you can add about
any functionality you want. From simple tags, to complicated tag structures. A simple
example for a 'foo' tag:
addTag(
'foo',
Zend_Markup_Renderer_RendererAbstract::TYPE_REPLACE,
array(
'start' => '-bar-',
'end' => '-baz-',
'group' => 'inline'
)
);
// now, this will output: 'my -bar-tag-baz-'
echo $bbcode->render('my [foo]tag[/foo]');
]]>
Please note that creating your own tags only makes sense when your parser also supports
it with a tag structure. Currently, only BBCode supports this. Textile doesn't have
support for custom tags.
Some renderers (like the HTML renderer) also have support for a
'tag' parameter. This replaces the 'start' and 'end' parameters, and
it renders the tags including some default attributes and the
closing tag.
Add a callback tag
By adding a callback tag, you can do a lot more then just a
simple replace of the tags. For instance, you can change the
contents, use the parameters to influence the output etc.
A callback is a class that implements the
Zend_Markup_Renderer_TokenInterface
interface. An example of a callback class:
Now you can add the 'upper' tag, with as callback, an instance
of the My_Markup_Renderer_Html_Upper
class. A simple example:
addTag(
'upper',
Zend_Markup_Renderer_RendererAbstract::TYPE_REPLACE,
array(
'callback' => new My_Markup_Renderer_Html_Upper(),
'group' => 'inline'
)
);
// now, this will output: 'my !up!TAG!up!'
echo $bbcode->render('my [upper]tag[/upper]');
]]>
List of tags