1

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.

4
  • Have you checked by inspect in browser?
    – DRUPWAY
    Commented Dec 3, 2014 at 6:58
  • Thanks Smalution . Yes I checked it in browser after all flush-cache and everything. tried all php function htmlspecialchars etc etc. Commented Dec 3, 2014 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?
    – DRUPWAY
    Commented Dec 3, 2014 at 7:11
  • When I inspect it showing same as browser. table td tr wrapped with my custom css class in div Commented Dec 3, 2014 at 7:39

1 Answer 1

0

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.

1
  • 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. Commented Feb 27, 2017 at 18:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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