False values not saved in page.md

When a variable is set to false it is removed from the page.md file. This is an issue because it means you can't test for true/false in a nav block. In a nav block(with include_content="true") if a value is not set for the current nav iteration's page and you use it in the nav block it will default to the current pages value for that variable. So if I have var1: "1" set on the current page and var1 is set to false on the nav page( and therefore no value is set at all) and I use it in a conditional it will return true even though it is false on that page.

So basically, this is unreliable:

{{ nav from="/" include_content="true" }}
  {{ if var1 }}
    <!-- output something -->
  {{ endif }}
{{ /nav }}

The workaround I am using now is to save the value as string instead of a boolean. So if you want it to be true you enter the string "pos" otherwise default to the string "neg". Then do something like this:

{{ nav from="/" include_content="true" }}
  {{ if var1 === "yes" }}
    <!-- output something -->
  {{ endif }}
{{ /nav }}

This works, but eliminates the use of checkboxes for booleans and is just kind of a pain.

I see only two solutions to this. Either save falsey values or create a setting for nav tags where you can exclude the parent scope.

>>>>>>> Unanswered <<<<<<<
0 Replies
1 Follower