I have my data from SQL with table HTML tags e.g. <tr> and <td>.

When I render it in Views it displaying all the HTML table tags without rendering it.

I put some code in .module file to pass this data using hook_views_post_execute I tried all the solution but nothing seems to work.

My views field is not rendering as table.

  • Have you checked by inspect in browser?
    Dec 3 '14 at 6:58
  • Thanks Smalution . Yes I checked it in browser after all flush-cache and everything. tried all php function htmlspecialchars etc etc. Dec 3 '14 at 7:00
  • After checking in browser you have seen your data display inside div not in table format but it should be in table format am i correct?
    Dec 3 '14 at 7:11
  • When I inspect it showing same as browser. table td tr wrapped with my custom css class in div Dec 3 '14 at 7:39

You need to unescape HTML. There are two working ways to accomplish this. First you can mark your field as "raw" and the html would render correctly. {{ your_field | raw }} should render ok.

As a second resort you can use twig's autoescape functionality:

{% autoescape false %}
{{ your_field }}
{% endautoescape %}

By this way you are telling twig not to escape html markup.

  • Please note that just posting code (with no explanation) is considered as "low quality posts", which is also why this answer showed up in the like named review queue. To avoid it gets deleted via moderation, I recommend you try to explain this code. Feb 27 '17 at 18:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.