Skip to content

Instantly share code, notes, and snippets.

@lolautruche
Created October 15, 2013 18:29
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lolautruche/6996323 to your computer and use it in GitHub Desktop.
Save lolautruche/6996323 to your computer and use it in GitHub Desktop.
Convert XmlText to HTML - eZ Publish 5
{% set html = content.getFieldValue( "my_xmltext_field" ).xml|xmltext_to_html5 %}
<div>
{{ html }}
</div>
<?php
// Assuming you're in a controller
$xmlTextValue = $myContent->getFieldValue( 'my_xmltext_field' );
/** @var \eZ\Publish\Core\FieldType\XmlText\Converter\Html5 $html5Converter */
$html5Converter = $this->get( 'ezpublish.fieldType.ezxmltext.converter.html5' );
$html = $html5Converter->convert( $xmlTextValue->xml );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment