<p>Your question is rather vaguely but if I'm right:</p>

<p>You could put an "if" statement around your "h1" element like,</p>

<pre><code>{% if loop.first %}&lt;h1&gt;This text will only be used if the lightswitch is active&lt;/h1&gt;{% endif %}
</code></pre>

<p>Or add a field to the block. Preferably a lightswitch. Which if enabled will show the H1 tag and wont if you dont activate it.</p>

<pre><code>{% if block.lightSwitch %}&lt;h1&gt;This text will only be used in the first loop&lt;/h1&gt;{% endif %}
</code></pre>

CC BY-SA 3.0
2017-02-06T11:22:21.587Z
Seems like putting my code into {% if loop.first %}{% endif %} makes it just hidden. All I want is to prevent it from being part of the block.
curious
CC BY-SA 3.0
2017-02-06T12:17:48.673Z
@J.Baptiste Should try the light switch code but can you be more clear with your question?
Justin Dekkers
CC BY-SA 3.0
2017-02-06T12:51:17.663Z
i just edited first post
curious
CC BY-SA 3.0
2017-02-06T11:03:35.317Z
2017-02-06T11:03:35.317Z
Justin Dekkers
<p>I fell like I'm missing an obvious thing, how to end block before I will start the new one?</p>

<pre><code>{% for block in entry.myMatrixField %}

{% if block.type == "heading" %}

    &lt;h3&gt;{{ block.heading }}&lt;/h3&gt;
    &lt;h1&gt;I don't want this text to be part of heading block&lt;/h1&gt;

{% elseif block.type == "text" %}

    {{ block.text|markdown }}

{% endif %}

{% endfor %}
</code></pre>

<h1>edit: here is my real code:</h1>

<pre><code>{# "Check" section #}
                    &lt;section class="wrapper style1 container special"&gt;
                        &lt;div class="row"&gt;
{# "Check" block #}
            {% elseif block.type == "check" %}
                            &lt;div class="4u 12u(narrower)"&gt;
                                &lt;section&gt;
                                    &lt;span class="icon featured fa-check"&gt;&lt;/span&gt;
                                    &lt;header&gt;
                                        &lt;h3&gt;{{ block.checkHeader }}&lt;/h3&gt;
                                    &lt;/header&gt;
                                    &lt;p&gt;{{ block.checkText }}&lt;/p&gt;
                                &lt;/section&gt;
                            &lt;/div&gt;
{# In this place block "check" should end #}
                        &lt;/div&gt;
                    &lt;/section&gt;
{# end of "check" section#}

{#beginning of "gallery section" #}
                        &lt;section class="wrapper style3 container special"&gt;
                        &lt;header class="major"&gt;
                            &lt;h2&gt;Next look at this &lt;strong&gt;cool stuff&lt;/strong&gt;&lt;/h2&gt;
                        &lt;/header&gt;

                        &lt;div class="row"&gt;
{# "gallery" block #}
            {% elseif block.type == "gallery" %}
                            &lt;div class="6u 12u(narrower)"&gt;

                                &lt;section&gt;
                                    &lt;a href="#" class="image featured"&gt;&lt;img src="someimagesoon.jpg" alt="" /&gt;&lt;/a&gt;
                                    &lt;header&gt;
                                        &lt;h3&gt;{{ block.imageHeader }}&lt;/h3&gt;
                                    &lt;/header&gt;
                                    &lt;p&gt;{{ block.imageText }}&lt;/p&gt;
                                &lt;/section&gt;
{# In this place block "gallery" should end #}
                            &lt;/div&gt;
                        &lt;/div&gt;

                        &lt;footer class="major"&gt;
                            &lt;ul class="buttons"&gt;
                                &lt;li&gt;&lt;a href="#" class="button"&gt;See More&lt;/a&gt;&lt;/li&gt;
                            &lt;/ul&gt;
                        &lt;/footer&gt;

                    &lt;/section&gt;

            &lt;/article&gt;
</code></pre>

<matrix>
How to skip fragments of code in Matrix?
# How to skip fragments of code in Matrix?

(Asked by: username_0 on 2017-02-06)

I fell like I'm missing an obvious thing, how to end block before I will start the new one?
{% for block in entry.myMatrixField %}

{% if block.type == "heading" %}

    {{ block.heading }}
    I don't want this text to be part of heading block

{% elseif block.type == "text" %}

    {{ block.text|markdown }}

{% endif %}

{% endfor %}

edit: here is my real code:
{# "Check" section #}
                    
                        
{# "Check" block #}
            {% elseif block.type == "check" %}
                            
                                
                                    
                                    
                                        {{ block.checkHeader }}
                                    
                                    {{ block.checkText }}
                                
                            
{# In this place block "check" should end #}
                        
                    
{# end of "check" section#}

{#beginning of "gallery section" #}
                        
                        
                            Next look at this cool stuff
                        

                        
{# "gallery" block #}
            {% elseif block.type == "gallery" %}
                            

                                
                                    
                                    
                                        {{ block.imageHeader }}
                                    
                                    {{ block.imageText }}
                                
{# In this place block "gallery" should end #}
                            
                        

                        
                            
                                See More

**Tags:** matrix


---

## 1 answers

### Answer by username_1 on 2017-02-06. Score: 1

Your question is rather vaguely but if I'm right:
You could put an "if" statement around your "h1" element like,
{% if loop.first %}This text will only be used if the lightswitch is active{% endif %}

Or add a field to the block. Preferably a lightswitch. Which if enabled will show the H1 tag and wont if you dont activate it.
{% if block.lightSwitch %}This text will only be used in the first loop{% endif %}

> **Comments:**
> **username_0**: Seems like putting my code into {% if loop.first %}{% endif %} makes it just hidden. All I want is to prevent it from being part of the block.  
> **username_1**: @J.Baptiste Should try the light switch code but can you be more clear with your question?  
> **username_0**: i just edited first post  

---

