latte html variable print string

8 months ago

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?

8 months ago

Kcko
Member | 302
+
0
-

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

8 months ago

Šaman
Member | 2308
+
+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)

8 months ago

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. :)

8 months ago

japlavaren
Backer | 412
+
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 ;)

7 months ago

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..

13 days ago

Viktoriia
Member | 1
+
0
-

Thank you from me too!)

12 days ago

duke
Member | 650
+
+1
-

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)