Expressions allow Horizon to use information from your feed to calculate, combine or transform values.
And, if that sounds veeery technical, don’t worry: iPaper handles the technical part, and you just get the outcome.
That outcome is Horizon automatically making smarter decisions about how your leaflet should look and behave - without you having to manually adjust anything.
📖 This guide explains:
The benefits of expressions
Instead of making manual edits to your leaflet, expressions allow Horizon to do it automatically.
This can help you…
Reduce manual work: Horizon automatically calculate or transform values for you.
Create more flexible layouts: Adapt elements and templates automatically.
Handle complex scenarios: Combine, compare or transform values to create exactly the output you want.
The workflow for expressions
The neat part about expressions in Horizon is that, even you’ve never heard of expressions before, you won’t be making any expressions yourself. We’ll do it for you.
The workflow is:
iPaper sets up an expression for you,
That expression produces a value,
Based on the value, a change will be made in your leaflet.
What are expressions?
An expression is a small piece of JavaScript code that produces a value.
Just to get an idea of the concept, here are some relatable examples:
5 + 3 produces the value 8
checking whether it’s raining right now produces true or false
If you’re interested in learning more about JavaScript and expressions, there are tons of other resources online, but you do not need to know how it works to get the benefits.
So, let’s look at some actual examples.
Examples of expressions in action
1. Dynamic information in your leaflet
Let’s say you want to number all the pages in your leaflet, such as ‘1 out of 12’, ‘2 out of 12’ etc.
You could do that manually, and create an area at the bottom of each page and manually fill in the correct number.
But that’s a lot of work, and it’s not dynamic: If you add another page in between the others, you’ll have to update all the following page numbers manually.
How expressions can help
But with expressions, this can be automated and dynamic:
Horizon automatically adds ‘X out of Y’ page numbers in a designated area.
The numbers dynamically updates if you add, remove pages or change the order – and also if you move the area to another page
The value for you
Less manual work
Always display the right information
💡 Such expressions could also be used for showing adding a header with the section name for each section.
2. Reduce clutter automatically
Not every offer has the same amount of space available. Sometimes, if an area is very small, all the elements may clutter the view, or worse: Make it hard to read.
For example, you might have several elements that looks great on a large offer but takes up too much space when the offer is smaller.
Here’s an example with Splash, Sales Aside 2 and product summary:
The splash is unreadable, and the entire offer would have more space ‘to breathe’ with fewer elements.
You could manually remove those elements, but that’s a lot of work.
How expressions can help
An expression can be used to determine whether there is enough space and add or remove the elements accordingly:
With a simple expression, Horizon can automatically:
Remove elements when the available area is too small
Add the elements when enough space is available
The value for you
Your offers will be less cluttered if there’s not enough space
No manual work.
3. Show the common name of multiple products in an offer
When combining several products into a single offer, Horizon will use the product name of the first product for the entire offer.
So, for example, ‘Devil costume’ + ‘Zombie Costume’ = ‘Devil Costume”:
Not ideal, right?
You could of course change it manually to just ‘Costume’, but imagine doing that for every single offer with multiple products.
How expressions can help
With an expression, Horizon can identify the common part of the product values and use it in your content, so it displays ‘Costume’.
With an expression, ‘Devil Costume’ + ‘Zombie Costume’ = ‘Costume’.
The value for you
Show information that is more representative of the total offer
No manual work
4. Change data from feed automatically
The feed data, or briefing data, might not always be formatted exactly how you'd like it to appear in your leaflet.
Let’s say your feed has a product’s title as “Decorative table lamp”, but you would like to have every word capitalized. You could change that in the feed, or in the leaflet editor – but again, that’s a lot of manual work.
Imagine if you needed to change that for all your products? Thankfully, it can be done automatically with an expression.
How expressions can help
An expression can be used to capitalize the first letter of every word, so it automatically becomes “Decorative Table Lamp” in your leaflet.
Value for you
Formatting happens automatically
No need to change your feed or briefing data
No manual work in the leaflet editor
How do you start using expressions?
If you have a use case where an expression could make save you time, just reach out to us. We'll create the expression and add it for you.
Not sure whether expressions can solve what you're trying to achieve? Reach out to us via the chat, and we'll be happy to help!
