Answers.Body: <p>Is there any reason you dont use a rich text field like redactor?
  You can make a custom config so that field only has h1,2,3 and no links, lists etc.</p>
  
  <p>And instead of having the class "measure-wide" on the heading element you can wrap it.</p>
  
  <p>Something like {{ block.heading }}
  Where block.heading is a custom redactor field.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-12-04T16:38:50.870Z
Answers.Text: That is a very good point. Lateral thinking at its best.
Answers.UserDisplayName: Dan Lee
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-12-04T16:30:48.040Z
Answers.LastActivityDate: 2018-12-04T16:30:48.040Z
Answers.UserDisplayName: Syversen
Body: <p>I am rendering some headings using twig and want to know if there is a better and more readable way of doing the following...</p>
  
  <pre><code>&lt;{{ block.headingType }} class="measure-wide"&gt;{{ block.headingText }}&lt;/{{ block.headingType }}&gt;
  </code></pre>
  
  <p><code>{{ block.headingType }}</code> is the value of the heading selected in the editor. The values are h2, h3, h4, h5 etc.</p>
  
  <p>The way the HTML headings are templated looks ugly (even though the rendering works). Is there a better way of rendering out the heading tags in twig based on the value selected?</p>
  
Tags: <templating>
Title: Rendering HTML Heading Elements in Twig
ThreadText: # Rendering HTML Heading Elements in Twig
  
  (Asked by: username_0 on 2018-12-04)
  
  I am rendering some headings using twig and want to know if there is a better and more readable way of doing the following...
  
  ```
  <{{ block.headingType }} class="measure-wide">{{ block.headingText }}</{{ block.headingType }}>
  
  ```
  
  `{{ block.headingType }}` is the value of the heading selected in the editor. The values are h2, h3, h4, h5 etc.
  
  The way the HTML headings are templated looks ugly (even though the rendering works). Is there a better way of rendering out the heading tags in twig based on the value selected?
  
  **Tags:** templating
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-12-04. Score: 3 | Accepted answer
  
  Is there any reason you dont use a rich text field like redactor?
  You can make a custom config so that field only has h1,2,3 and no links, lists etc.
  
  And instead of having the class "measure-wide" on the heading element you can wrap it.
  
  Something like {{ block.heading }}
  Where block.heading is a custom redactor field.
  
  > **Comments:**
  > **username_0**: That is a very good point. Lateral thinking at its best.  
  
  ---
  
  