I’m creating a landing page builder and I’m including all content in frontmatter and having partials pull that local data in dynamically. But I would like to include some sort of check to see if that front matter data exists, and if it doesn’t, I’d like to tell the partial to not render a blank tag.
For instance. My frontmatter may look like this:
cta:
headline: This is a call to action.
subhead: We really think you're gonna love us.
button_text: Sign Up
My partial call looks like this:
= partial(:'partials/landing_builder/_cta_form.slim', :locals => { :headline => current_page.data.cta.headline, :subhead => current_page.data.cta.subhead, :button_text => current_page.data.cta.button_text })
And the partial code is something like this:
section.landing_cta
.row.align-center
.small-11.columns
h2 = headline
p = subhead
Can I wrap the h2
and p
tags in some sort of if statement that checks to see if that content exists in frontmatter?