Is it possible to use Twig in a Rich Text Field? I have global variables that I want to include in Rich Text Fields, for example:

This is a rich text field, call us today at at {{ phone.number }}!


This doesn't work out-of-the-box, are there any ways of doing this? I am coming from working in another CMS where this was possible to do. 

Update: Specifically in this case I the global variable includes a javascript code that dynamically updates the phone number with a tracking number:

&lt;script type="text/javascript"&gt;{ document.write(_ibp_phone_number); }&lt;/script&gt;
The Technical Way

You can do this using Twig's template_from_string function and the raw filter.  In your template code you would output your Rich Text field:

{{ include(template_from_string(entry.richTextFieldHandle)|raw) }}


And within your Rich Text field you could reference your global with the same syntax you normally would in Twig as you described above:

This is a rich text field, call us today at {{ phone.number }}!




A More User-Friendly Way

The Rich Variables Plugin allows you to give a user control over adding Global Variables to your Rich Text field.

This approach will be a bit more limited in what you can accomplish, but probably toward a more user-friendly outcome for your content managers.