How to use blocks and if statement in statamic

308 views Asked by At

I'm trying to use blocks with if statement inside but when I use {{ if }} condition everything outside of it is shown double content

example:

{{ blocks }}
... more code and 2 more IFs above
  {{ if set == "hero-1" }}
<div class="container ">
    <section class="hero">
        <div class="hero-body">
            <div class="padding-50 has-text-centered">
                <h1 class="h1">
                    Heading
                </h1>
                <h2 class="h2">
                    Heading 2
                </h2>
            </div>
        </div>
    </section>
</div>
  {{ /if }}
<hr>
... more code here

{{ /blocks }}

in this case, it will result Heading shown ok, Heading 2 shown ok, but HR will be duplicated, any other way then set it to some of if statements?

1

There are 1 answers

0
Jack McDade On

If you move the <hr> inside the if statement, it won't be duplicated.