title: How to define a Django template method to avoid duplicating of code in html?
body: <p>I have two different UI pages. In both of the pages, 2 out of 5 html elements are common and rest 3 are not. How to avoid duplicating the code?</p>
  
  <p>Current implementation:</p>
  
  <pre><code>{% if page 1 %}
        &lt;h3&gt; Page 1 &lt;/h3&gt;
        &lt;div&gt; Element1 &lt;/div&gt;
        &lt;div&gt; Element2 &lt;/div&gt;
        &lt;div&gt; Element3 &lt;/div&gt;
        &lt;div&gt; Element4 &lt;/div&gt;
        &lt;div&gt; Element5 &lt;/div&gt;
  {% elif page 2 %}
        &lt;h3&gt; Page 2 &lt;/h3&gt;
        &lt;div&gt; Element1 &lt;/div&gt;
        &lt;div&gt; Element2 &lt;/div&gt;
        &lt;div&gt; Element6 &lt;/div&gt;
        &lt;div&gt; Element7 &lt;/div&gt;
        &lt;div&gt; Element8 &lt;/div&gt;
  </code></pre>
  
  <p>How to avoid writing  Element1            Element2  twice ?</p>