MarkupBundle
============
The MarkupBundle provides the feature of extending output formats as with
different so called tags. These tags will be automatically parsed and replaced
before the response will be sent.
Example
-------
This example contains a sulu-related example. The tag ``sulu:link`` represents
a link to another page. This tag will be replaced via a valid anchor where the
`href` attribute contains the UUID of the page.
.. code-block:: html
**Results into:**
.. code-block:: html
Page Title
Core Tags
---------
.. toctree::
:maxdepth: 1
link
media
Extending
---------
To enable replacement of your custom tags you can define a service which
implements the ``TagInterface``.
.. code-block:: php
class LinkTag implements TagInterface
{
/**
* Returns new tag with given attributes.
*
* @param array $attributes attributes array of each tag occurrence.
*
* @return array Tag array to replace all occurrences.
*/
public function parseAll($attributesByTag) {
$result = [];
foreach($attributesByTag as $tag => $attributes) {
$url = ; // load url via uuid from document-manager
$pageTitle = ...; // load page-title via uuid from document-manager
$result[$tag] = sprintf('%s', $url, $pageTitle, $attributes['content']);
}
return $result;
}
}
When registering your service simple add the tag
````.
.. note::
In combination with the plugin-system of the :doc:`../admin/ckeditor` you
can easily provide a user-interface to manage your custom tag.
Namespaces
----------
Namespaces will be used to find tags with a special behavior. The default
namespace is ``sulu``, but you can register your own namespace by adding a new
service and register your ``TagInterface`` implementations with this new
namespace.
.. code-block:: xml
With this definitions you can use ```` in your
response.