首页 > 解决方案 > Nesting liquid tag to select a list item

问题描述

Hey I'm wondering if you could help me with some Liquid coding I am struggling with.

I am using Liquid with customer.io in order to code an email template.

customer.io uses data from user attributes e.g {{customer.sub_speciality_id}} as well as data from a trigger sent as a JSON e.g {{trigger.test}}

I am using the following tag {{trigger.sub_specialities.3[0].title}}

Which looks in the JSON under for the values from the key "sub_specialities" it then chooses the section whose key is "3" which is a list, then picks the first item in that list and returns the title

That works fine.

But what I would like to do is to replace 3 with a liquid tag based off the customer attribute sub_speciality which is stored as {{customer.sub_speciality_id}}

so in a way {{trigger.sub_specialities.{{customer.sub_speciality_id}}[0].title}}

But I know you can't do liquid like that. How would I go about doing that?

标签: emailshopifyliquidmailchimp

解决方案


推荐阅读