[TYPO3-team-core-v5] RFC: TagBuilder
Bastian Waidelich
bastian at typo3.org
Sun Apr 5 19:02:07 CEST 2009
Hi everybody,
Whenever we need to create HTML (or XML) tags from PHP (e.g. in the
tag-based view helpers for Fluid) we end up concatenating long strings
like this:
return '<a href="' . $uri . '" ' . $this->renderTagAttributes() . '>' .
$this->renderChildren() . '</a>';
This is not very readable and very error-prone.
I think, it would be nice, to have some kind of Tag-builder, so that you
could write s.th. like:*
$tag = new Tag('a');
$tag->addAttribute('href', $uri);
$tag->addAttributes($this->tagAttributes());
$tag->setContent($this->renderChildren());
return $tag->render();
I think that could be a neat little class for TYPO3 v4 _and_ FLOW3.
What do you think,
Useful?
Where to put this class and how to name it?
All the best and have a great week!
Bastian
* In the case of Fluids tag-based View helpers the base class could even
create the tag and you'd only need to write:
$this->tag->addAttribute('href', $uri);
More information about the TYPO3-team-core-v5
mailing list