title: How to include context variable in a wagtail cms field?
body: <p>I am looking for a way to render a variable that will be available in the context of the the page where the cms page will be rendered.</p>
  
  <p>Ex:
  I have in the context the logged in user and I also have the last transaction he made on the website.</p>
  
  <p>I would like the text in the rich text field in Wagtail to be like this so that the marketing team can tweak the copy.</p>
  
  <blockquote>
    <p>Hello ||firstname|| thanks for your purchase. ||productname|| will be
    shipped to you soon. The expected delivery date is
    ||expected_delivery_date||</p>
  </blockquote>
  
  <p>To be less confusing I replace the double brackets by double pipes to show that the templating system does not need to be django templates for those ones. Simple templating is enough maybe using <a href="https://docs.python.org/3.4/library/string.html#template-strings" rel="nofollow noreferrer">https://docs.python.org/3.4/library/string.html#template-strings</a>
  I think I can achieve this by doing:</p>
  
  <ol>
  <li>A stream field that would have blocks of rich text field and a custom block with the possible context variable they can use</li>
  <li>A custom render function that would regex and replace the merge tags in the rich text block with the context values</li>
  <li>Create a new filter for simple templating. ex: {{ page.body|richtext|simpletemplate }}</li>
  </ol>
  
  <p>Is there any more obvious way or out of the box way to do templating from within a rich text field?</p>