#Jinja macro catch error
1 messages · Page 1 of 1 (latest)
AFAIK there's no way to do that in jinja - do you know why it's throwing the errors so can test for those inputs before they cause an issue?
Yes I do - currently trying to see what I can do about that - but for some reason my if sentences for the result from the macro doesn't really work :/ Just tried (just for the sake of test) to return 0 when the conditions isn't met, but
{% set cheapest = FindCheapestPeriod(earliestStartTime , (dtime-periodLength) , periodLength, false) %}
{% if cheapest == "0" %}
{{ oldStart }}
{% else %}
{{ cheapest }}
{% endif %}
still returns cheapest and not oldStart
Try removing the " around the zero
Same result
That's checking for = a string 0 not the number 0
Hmmm
Is this @pure karma's thing? He probably knows how to fix it
passes the buck
Don't know what FindCheapestPeriod is. Mine is cheapest_energy_hours
but you probably have a whitespace issue
{% set cheapest = FindCheapestPeriod(earliestStartTime , (dtime-periodLength) , periodLength, false) %}
**{{ cheapest }}**
try that in devtools > templates, I expect you will have whitespace around the result
you need to add a dash to every time you use the curly brackets in your templates
so {%- -%} and {{- -}}
or trim the result
{% set cheapest = FindCheapestPeriod(earliestStartTime , (dtime-periodLength) , periodLength, false) %}
**{{ cheapest | trim }}**
if they are type errors, check the type before executing