I have tried several solutions to get my node--view--viewname.html.twig to print out an iframe, but no success so far.

I have in my theme_preprocess_node function the following:

$vars['vimeo_embed'] = array(
    '#markup' => \Drupal\Core\Render\Markup::create($vimeo_embed),
    '#allowed_tags' => ['iframe','a','html'],
  );

following the advice of this thread: http://drupal.stackexchange.com/questions/184963/pass-raw-html-to-markup

and in my node--view--viewname.html.twig all the following does not work:

<iframe src="{{ node.field_vimeo_embed_url[0]['value'] }}"></iframe>
{{ node.field_vimeo_embed_url[0].getValue()['value'] }}
{{ vimeo_embed['#markup']| raw }}
{{ vimeo_embed['#markup'] }}
{% verbatim %}
{{ vimeo_embed['#markup']| raw }}
{{ '<iframe></iframe>' | raw('html') }}
<iframe></iframe>
{% endverbatim %}

I have tried changing the output of mytheme_preprocess_views_view_field(&$variables) because I thought the problem was to be found in the advancedRender function, but to no avail.

Any help with this is greatly appreciated.

Comments

h_dries created an issue. See original summary.

h_dries’s picture

The problem turned out to be caused in my own controller, added #markup and #allowed_tags here and now it works.

$project = node_load($nid);
		$pview = node_view($project);
		$output = render($pview);

$blockview = views_embed_view("werkingen",'block_1');
		$output .= render($blockview);

		$build = array(
      '#type' => 'markup',
      '#markup' => \Drupal\Core\Render\Markup::create($output),
      '#allowed_tags' => ['iframe','a','html'],
    );
    return $build;
h_dries’s picture

Status: Active » Closed (fixed)