How do I prevent Twig from encoding HTML? I've created a field type that stores its value as a model. That model’s __toString() method returns the result of a craft()-&gt;templates-&gt;render() call:

public function render() 
{
    $render = craft()-&gt;templates-&gt;render('myplugin/templates/mymodeltemplate');
    return $render;
}

public function __toString()
{
    return $this-&gt;render();
}


When I output the model from a template, like so:

{{ entry.myField }}


Twig encodes the resulting HTML as a string with HTML entities.  Running the string through html_entity_decode() before returning it in __toString() doesn't help.  I'm assuming this string formatting is happening somewhere at the Twig level.

Being new to Craft, I'd love to understand a little more of what's going on here.  How does the string representation of an element model get passed to and handled by Twig?
Whenever you output anything with Twig’s {{ output tags }}, the contents will get encoded by default. You have to pass the content through the |raw filter in order for it to be output verbatim.

{{ entry.myFieldHandle|raw }}