I'm trying to make a div have a location inside of it based on the state of two variables, for example if $city = 'New York'
and $state = 'NY'
the div would display New York, NY
. However, it's not working and I think it has to do with scoping. Here's my jade:
$city = data.City
$state = data.State
$locString = ""
if $city != ""
$locString = $locString + $city
if $city != "" && $state != ""
$locString = $locString + ", "
if $state != ""
$locString = $locString + $state
.location #{$locString}
This is ending with $locString being empty, but if I print off $locString inside the if statements it has only the most recently added value, suggesting that it is redeclaring a local copy of the variable inside of each if statement. I can't find anything about this in the reference http://jade-lang.com/reference/
I woud suggest this:
Take care of the "var" and "-".
Check "Variables" part on -> https://naltatis.github.io/jade-syntax-docs/