1

I am passing my HTML string to the $content variable and trying to display it, in the result I see raw HTML tags instead of the string markup.

Controller:

$content = "<strong>Test markup</strong>";

index.tpl:

{$content} - displays just raw variable content without markup: <strong>Test markup</strong> INSTEAD of the Test markup.

When I type manually the above variable content in the index.tpl then it works just fine so it seems to be some variable-related issue.

What have I tried:

{content|nofilter} - to be sure its not caused by any of the Smarty's variable filters.

Could someone help me to localize the problem?

Oswald
  • 31,254
  • 3
  • 43
  • 68
Lucas
  • 3,517
  • 13
  • 46
  • 75
  • possible duplicate of [show a smarty variable with html content](http://stackoverflow.com/questions/16449583/show-a-smarty-variable-with-html-content) – Sergiu Paraschiv Jan 20 '14 at 19:45
  • @Sergiu Parashiv You're right. Its strange I couldnt find that before, thanks. I have flagged my question as a duplicate. – Lucas Jan 20 '14 at 19:48
  • Well, it _is_ counter-intuitive. It should just work. As a side note: why _are_ you using Smarty? – Sergiu Paraschiv Jan 20 '14 at 19:49
  • @SergiuParaschiv Mostly because its a fast and flexible template engine + http://www.smarty.net/why_use :) – Lucas Jan 20 '14 at 20:41
  • 3
    First I would check if the property `$smartyInstance->escape_html` is set to false. Have you really tried `{content|nofilter}` ? It looks syntactical wrong for me. I'm only familiar with this syntax `{$content nofilter}` – sofl Jan 23 '14 at 17:38

1 Answers1

2

Please try:

{$content|unescape:'html'}

More details on: http://www.smarty.net/docs/en/language.modifier.unescape.tpl

Marcin Barylski
  • 438
  • 4
  • 15