# Is it possible to use an OR / AND conditional rather than IF...ELSE?

**URL:** <https://discourse.gohugo.io/t/is-it-possible-to-use-an-or-and-conditional-rather-than-if-else/10958>\
**Category:** support\
**Created:** [March 9, 2018, 5:45am UTC](https://discourse.gohugo.io/t/is-it-possible-to-use-an-or-and-conditional-rather-than-if-else/10958 "2018-03-09T05:45:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Randy\_Lough](https://avatars.discourse-cdn.com/v4/letter/r/85e7bf/32.png) [@Randy\_Lough](https://discourse.gohugo.io/u/Randy_Lough)\
**Post date:** [March 9, 2018, 5:45am UTC](https://discourse.gohugo.io/t/is-it-possible-to-use-an-or-and-conditional-rather-than-if-else/10958/1 "2018-03-09T05:45:10Z")

</div>

So I’m trying to reduce the number of `IF/ELSE` statements. Is there a way I can incorporate an `OR` conditional inside an `IF` statement to check if either param A or param B is set?

This obviously doesn’t work, but kinda what I am after

```auto
---
media:
    image:
    svg: this is set
---

```

```auto
{{ with .media }}
  {{if ( or ( .image ) ( .svg )) }}
     <div class="media">
        {{.image}}
        {{.svg}}
     </div>
  {{end}}
{{end}}

```

Ideally I’m looking for something that’s more readable without having multiple IF statements just to check if some parameters with the same context are there.

I’ve tried using a variation of `not (eq .image "") | or (eq .svg "")` and `isset` but I keep getting an error of `wrong number of args for safeHTML: want 1 got 0`.

Is it possible to use an OR conditional for this purpose?

---

<div class="post-metadata">

**Author:** ![Mikhail](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/mikhail/32/1138_2.png) [@Mikhail](https://discourse.gohugo.io/u/Mikhail)\
**Post date:** [March 9, 2018, 9:16am UTC](https://discourse.gohugo.io/t/is-it-possible-to-use-an-or-and-conditional-rather-than-if-else/10958/2 "2018-03-09T09:16:47Z")

</div>

> [@Randy\_Lough](#):
>
> {{if ( or ( .image ) ( .svg )) }}

```auto
{{ if or ( .image ) ( .svg ) }}
{{ if and ( .image ) ( .svg ) }}
{{ if or ( .image ) (not .svg ) }}

```

---

<div class="post-metadata">

**Author:** ![Mikhail](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/mikhail/32/1138_2.png) [@Mikhail](https://discourse.gohugo.io/u/Mikhail)\
**Post date:** [March 9, 2018, 9:27am UTC](https://discourse.gohugo.io/t/is-it-possible-to-use-an-or-and-conditional-rather-than-if-else/10958/3 "2018-03-09T09:27:10Z")

</div>

> [@Randy\_Lough](#):
>
> {{ with .media }}

I hope this is a typo. To access user variables, you must use .Params. `{{ with .Params.media }}`

---

<div class="post-metadata">

**Author:** ![Randy\_Lough](https://avatars.discourse-cdn.com/v4/letter/r/85e7bf/32.png) [@Randy\_Lough](https://discourse.gohugo.io/u/Randy_Lough)\
**Post date:** [March 9, 2018, 5:55pm UTC](https://discourse.gohugo.io/t/is-it-possible-to-use-an-or-and-conditional-rather-than-if-else/10958/4 "2018-03-09T17:55:11Z")

</div>

Thanks @Mikhail. Turns out I had a set of old parameters that I forgot to change to the newer cleaner version - which was causing the errors. Frustrating lesson learned. But your method works, thanks!

Also in this particular case it wasn’t a typo. My media parameter is within a `range` statement.
