atk4 / ui

Robust and easy to use PHP Framework for Web Apps
https://atk4-ui.readthedocs.io
MIT License
440 stars 105 forks source link

HTML text can be passed easily to `Text` #2040

Open mvorisek opened 1 year ago

mvorisek commented 1 year ago

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.

DarkSide666 commented 1 year ago

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.

mvorisek commented 11 months ago

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