Shopify Liquid-此JS代码在液体中等同于什么?
液体似乎非常限制,我真的无法弄清楚如何使液体等效于以下JS代码:
const allIngredients = {
vitamin_c: {
title: "Vitamin C",
description: "Some text here",
},
vitamin_k: {
title: "Vitamin K",
description: "Some text here",
}
}
const productIngredients = ["vitamin_k"]
productIngredients.map(ingredient => {
console.log(allIngredients[ingredient])
});
更新:
我有多种产品,每种产品都包含多种成分。这些成分存储在product.Ingredients
中。
结构:
{
"vitamin_c" => {
"ingredient_title" => "Vitamin C",
"ingredient_description" => "Some text here"
},
"vitamin_k" => {
"ingredient_title" => "Vitamin K",
"ingredient_description" => "Some text here"
},
...
}
在产品Metafield中,我添加了上述JSON IE Vitamin_C
和Vitamin_k
的键。
现在,我要做的是用product.Ingredients
JSON映射Metafield值,然后在我的页面上打印IngreDient_Title和ingredient_description。
感谢您的帮助!
Liquid seems to be very restrictive and I am not really able to figure out how to get the liquid equivalent of the below JS code:
const allIngredients = {
vitamin_c: {
title: "Vitamin C",
description: "Some text here",
},
vitamin_k: {
title: "Vitamin K",
description: "Some text here",
}
}
const productIngredients = ["vitamin_k"]
productIngredients.map(ingredient => {
console.log(allIngredients[ingredient])
});
Update:
I have multiple products and each product comprises of multiple ingredients. These ingredients are stored in product.Ingredients
.
Structure:
{
"vitamin_c" => {
"ingredient_title" => "Vitamin C",
"ingredient_description" => "Some text here"
},
"vitamin_k" => {
"ingredient_title" => "Vitamin K",
"ingredient_description" => "Some text here"
},
...
}
In the product metafield, I am adding the keys of the above json i.e. vitamin_c
and vitamin_k
.
Now what I want to do is to map the metafield values with the product.Ingredients
json and print the ingredient_title and the ingredient_description on my page.
Thanks for the help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论