Lava Example - 68
Prompt
Our predecessor at the church created this Lava template, and we need to make it easier to understand.
Practice rewriting this template so the functionality doesn't change, but it's clearer for our future selves to understand!
Initial Code
{% assign attr1 = Person | Attribute:'BaptismDate' %}
{% assign attr2 = Person | Attribute:'Employer' %}
{% assign attr3 = Person.PrimaryFamily | Attribute:'IsFosterFamily' %}
<p>{{ Person }} works for {{ attr2 }}
and is {% if attr1 == '' %}not {% endif %}baptized.</p>
{% if attr3 == 'Yes' %}
<p>They are a foster family.</p>
{% endif %}
Solution Lava
{% assign baptismDate = Person | Attribute:'BaptismDate' %}
{% if baptismDate != null and baptismDate != empty %}
{% assign isBaptized = true %}
{% else %}
{% assign isBaptized = false %}
{% endif %}
{% assign employerName = Person | Attribute:'Employer' %}
{% assign isFosterFamily = Person.PrimaryFamily | Attribute:'IsFosterFamily' %}
<p>{{ Person }} works for {{ employerName }}
and is {% if isBaptized == false %}not {% endif %}baptized.</p>
{% if isFosterFamily == 'Yes' %}
<p>They are a foster family.</p>
{% endif %}