Template Variables

Make your slides dynamic using template variables

Say for example, that you want to address your customer by name on your Zigpoll. Something like:

Welcome Jason, do you have a minute to fill out our poll?

You can do this easily by using Template Variables. Template variables allow you dynamically adjust the copy in your slide according to some set of javascript variables on your page. In order to do something like the example above you would perform the following steps.

1. Add a template variable to your page using javascript. In this example we will call it name and we will pull it using PHP from a user object. You will want to replace this depending on how your website is configured.

// Add this code right below your Zigpoll embed code.
window.Zigpoll.templateVariables = {
name: <?php echo $user.name ?>
}

2. Now that you have your template variable set up as name you can access it in your slide. In our example we will be putting it into the copy section of the slide. So in the copy input box, we can enter something like this:

Hey, {{#if name}}{{name}}{{else}}Mysterious Person{{/if}} do you have a minute to fill out our poll?

Now the slide will print the user's name if it exists or "Mysterious Person" if it does not.

You can add any variable you like to the templateVariables javascript object and you will be able to access it in the slide's title, subtitle, or copy inputs. If you would like to add loops or conditional logic, you can use any valid syntax from the handlebars spec.