Using a set variable in an include for an if / else

Hi, struggling to work out how to do the following
template which calls an include for a menu, because the menu code is outputted twice (once for mobile, then again for the full screen menu) there is a little difference if the html code before hand for the right containers.

Can i set a variable to test in the include

{% set menunavigation = “responsive” %}
{% include ‘partials/navigation.html.twig’ %}
{% endblock %}

then later on
{% set menunavigation = “fullscreen” %}
{% include ‘partials/navigation.html.twig’ %}
{% endblock %}

then in the standard navigation.html.twig

{% if menunavigation=“responsive” %}

    { else% } {% if menunavigation="fullscreen" %}
      {% endif %}

      then the normal navigation code
      not sure if the scope would be seen or it needs to be passed as variable or a function

      could some one clarify and tell me where I am going wrong :-/
      Thank you

Had a nights sleep and came away from it for a while and ended up resolving it myself after reading a post so wanted to post my findings of a novice and maybe it will help someone else out there.

To send a variable to an include is the easiest way of calling a way of testing something.

Use something like this

in my base.html.twig
{% include ‘partials/navigation.html.twig’ with {‘menunavigation’ : ‘mobile’} %}
where menunavigation is the variable and mobile is the data

later on in my code I call the same partial navigation with this command
{% include ‘partials/navigation.html.twig’ with {‘menunavigation’ : ‘responsive’} %}

then in my navigation.html.twig

{% if menunavigation == “mobile” %}

    {% endif %}

    {% if menunavigation == “responsive” %}

      {% endif %}

      Then it loops through the standard navigation.html.twig code

      So why did I struggle and create this post … SYNTAX !!!
      Something I didn’t realise was the sensitivity of grav and a couple of crafty space ended up in my “if” statement, so me thinking I cant work out the logic operators of an “IF” or that the variable is not being seen, whilst all along it was a cheeky little space which had ended up in my of my {% endif %} — mine originally was {% endif % } <basically a space between the % and the bracket, foolish error but stumped me as you just kept looking over it.

      Woo hoo it works, this is very handy instead of writing a separate file include file for each of the instances.

      Still not sure how the variable is set (global or based on the calling page, or if for good practice I should destroy the variable myself after completing the code.

      Hope this helps someone who is learning :slight_smile: but happy for input if anyone has a better way or better technique of doing this .