I am looking to render a handlebars partial via the Lookup helper. This isn't a problem, I can do that with this code:
{{> (lookup . 'type') }}
However, if the variable type
doesn't render a value that is in my partials directory, then a 500 error throws. Handlebars supports this with failover content. Such as:
{{#> myPartial }}
Failover content
{{/myPartial}}
My question is, can I combine the lookup with the failover?
I was hoping to do something like:
{{#> (lookup . 'type') }}
Failover content
{{/(lookup . 'type')}}
Thank you @76484 but I think I found what I was looking for:
{{#> (lookup . 'type') }}<!-- Return Nothing if Undefined -->{{/undefined}}
This avoids the need for a helper, and does exactly what I was looking for!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With