Using Conditional Logic with HAPI

With our HAPI language you can now include conditional logic on whether or not to display a data-pv section.  Simply add the following tag to the component section:

data-pv-conditional="{@variable@} = value}"

{@variable@} is the variable that's either passed in the parameters section or via the query string in the URL.  The value should be plain text or numbers without any quotes.

For example, notice how we display only the certain block that matches the {@sport@} parameter. 

<div data-pv-component="text">
  What sport do you like?
<div data-pv-component="text" data-pv-conditional="{@sport@} = baseball">
<div data-pv-component="text" data-pv-conditional="{@sport@} = basketball">
Have more questions? Submit a request


Please sign in to leave a comment.