atk4/ui

HTML text can be passed easily to `Text`

mvorisek opened this issue · 2 comments

Example:

$t = Text::addTo($parentView)->set('Name <b>popup');
var_dump($t->render());

image

Text class should be probably removed completely in favor of View only.

I don't see reason why to remove this class. Text is quite standard thing to do even if it can easily be done by using View.

I think set() should not allow HTML and should probably use strip_tags to clean it up.
And there should be setHtml() method, in addition to addHtml() which we already have, to allow developer to intentionally set html text there.

Also could think about moving addParagraph functionality to separate class Paragraph extends Text because of same reason - kind of simple View <p> tag class, but could be useful in many cases so it's good to have some shortcut classes too.

one solution can be to rework every HTML string to be wrapped using HtmlTemplate\Value, as this would imply a frequent imports, rename also the class to HtmlValue