0

I want to check for null values in Scriban.

{{ if (o_model.address.id) }}
<div  style="text-align: center;"><h5>Address {{ o_model.address.id}}</h5><br /></div>
{{ end }}

I am getting this error

error : Object `o_model.address` is null. Cannot access member: o_model.address.id

What I am doing wrong here?

  • 2
    Have you tried something like if (o_model.address && o_model.address.id)? – Marek Musielak Aug 7 at 7:30
  • Not sure what part of Object o_model.address is null is unclear – Mark Cassidy Aug 7 at 11:37
  • @MarkCassidy thanks it works – Owais Ahmed Aug 10 at 2:49
  • @MarkCassidy Marek solutions works thanks – Owais Ahmed Aug 10 at 2:49
0

This works

{{ if (o_model.address)}}
    {{ if (o_model.address.id)}}
    {{ end }} 
{{ end }}

Thanks Marek

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.