Zend_Markup-Renderers.xml 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <sect1 id="zend.markup.renderers">
  4. <title>Zend_Markup Renderers</title>
  5. <para>
  6. <classname>Zend_Markup</classname> is currently shipped with one renderer, the
  7. <acronym>HTML</acronym> renderer.
  8. </para>
  9. <sect2 id="zend.markup.renderers.add">
  10. <title>Adding your own tags</title>
  11. <para>
  12. By adding your own tags, you can add your own functionality to the
  13. <classname>Zend_Markup</classname> renderers. With the tag structure, you can add about
  14. any functionality you want. From simple tags, to complicated tag structures. A simple
  15. example for a 'foo' tag:
  16. </para>
  17. <programlisting language="php"><![CDATA[
  18. // Creates instance of Zend_Markup_Renderer_Html,
  19. // with Zend_Markup_Parser_BbCode as its parser
  20. $bbcode = Zend_Markup::factory('Bbcode');
  21. // this will create a simple 'foo' tag
  22. // The first parameter defines the tag's name.
  23. // The second parameter takes an integer that defines the tags type.
  24. // The third parameter is an array that defines other things about a
  25. // tag, like the tag's group, and (in this case) a start and end tag.
  26. $bbcode->addTag(
  27. 'foo',
  28. Zend_Markup_Renderer_RendererAbstract::TYPE_REPLACE
  29. | Zend_Markup_Renderer_RendererAbstract::TAG_NORMAL,
  30. array(
  31. 'start' => '-bar-',
  32. 'end' => '-baz-',
  33. 'group' => 'inline',
  34. )
  35. );
  36. // now, this will output: 'my -bar-tag-baz-'
  37. echo $bbcode->render('my [foo]tag[/foo]');
  38. ]]></programlisting>
  39. <para>
  40. Please note that creating your own tags only makes sense when your parser also supports
  41. it with a tag structure. Currently, only BBCode supports this. Textile doesn't have
  42. support for custom tags.
  43. </para>
  44. </sect2>
  45. </sect1>