latte html variable print string

hsynucak
Member | 8
+
0
-

hi;
presenter string html variable latte echo problem;

sample:

presenter code :
$this->template->test = “<b>bolder text</b>”;

latte code:

{$test}

show browser : string

<b>bolder text</b>

but me do you :

bolder text

understand me?

Kcko
Member | 468
+
0
-

use noescape filter. Btw tvoje anglictina je fakt něco, původně jsem myslel, že se jedná o vtip.

Šaman
Member | 2659
+
+1
-

{$test|noescape}

Kcko wrote:

use noescape filter. Btw tvoje anglictina je fakt něco, původně jsem myslel, že se jedná o vtip.

IMO he is not understand czech.

Last edited by Šaman (2018-12-17 00:57)

hsynucak
Member | 8
+
0
-

Šaman wrote:

{$test|noescape}

Kcko wrote:

use noescape filter. Btw tvoje anglictina je fakt něco, původně jsem myslel, že se jedná o vtip.

IMO he is not understand czech.

thank you. working this code. :)

japlavaren
Member | 404
+
0
-

if you need to pass variable with html code to template with html code, you can use ` Nette\Utils\Html`

$this->template->variable =  Nette\Utils\Html::el()->sendHtml("<b>bolder text</b>");

this works also with nette forms captions and others ;)

hsynucak
Member | 8
+
0
-

japlavaren wrote:

if you need to pass variable with html code to template with html code, you can use ` Nette\Utils\Html`

$this->template->variable =  Nette\Utils\Html::el()->sendHtml("<b>bolder text</b>");

this works also with nette forms captions and others ;)

thank you..

Viktoriia
Member | 1
+
0
-

Thank you from me too!)

duke
Member | 650
+
+2
-

japlavaren wrote:

if you need to pass variable with html code to template with html code, you can use ` Nette\Utils\Html`

$this->template->variable =  Nette\Utils\Html::el()->sendHtml("<b>bolder text</b>");

this works also with nette forms captions and others ;)

Not sendHtml but setHtml:

$this->template->variable =  Nette\Utils\Html::el()->setHtml("<b>bolder text</b>");

It is also possible to use addHtml (or even addText in this case) if you create the b element first like this:

$this->template->variable =  Nette\Utils\Html::el('b')->addHtml("bolder text");

Last edited by duke (2019-08-12 21:14)