1

This question already has an answer here:

I am getting following error in drupal 8 :

The website encountered an unexpected error. Please try again later.

Twig_Error_Syntax: Unknown "check_markup" function.

Twig template line :

{% set featured_portfolio_text = check_markup(featured_portfolio_array['field_portfolio_link_text']['#items'][0]['value'],'full_html') %}

Is there any alternative to check_markup function for twig?

marked as duplicate by Neograph734, Shawn Conn, kiamlaluno Mar 8 '17 at 18:00

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

0

This seems like something you could do in a preprocess function and create that variable. At that level, you can use check_markup to check it.

Be sure to see the two notes on the docs page:

Note: Because filters can inject JavaScript or execute PHP code, security is vital here. When a user supplies a text format, you should validate it using $format->access() before accepting/using it. This is normally done in the validation stage of the Form API. You should for example never make a preview of content in a disallowed format.

Note: this function should only be used when filtering text for use elsewhere than on a rendered HTML page. If this is part of a HTML page, then a renderable array with a #type 'processed_text' element should be used instead of this, because that will allow cacheability metadata to be set and bubbled up and attachments to be associated (assets, placeholders, etc.). In other words: if you are presenting the filtered text in a HTML page, the only way this will be presented correctly, is by using the 'processed_text' element.

Here is a similar question/answer (albeit from 2014) that may still apply.

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