当我需要在JS中使用一个类JSON的对象,并在每个块中使用不同的数据并遍历该对象时,我通过pug生成HTML代码。
让我用代码描述一下:
var footerMenu = {
left: {
title: "sometitle",
list: [
{
title: "First thing to do",
text: "wake up and brush some teeth"
},
{
title: "Second thing to do",
text: "start coding"
},
(...)
当需要使用一些标签来样式化属性footerMenu.left[0].text
中的文本时,问题就出现了。
我需要像这样的东西
...... text: "wake up and #[span.color-red brush] some teeth"
但是,当然pug将其读取为简单的字符串。
我不想手动编写每个块,我如何使用pug在JSON对象中保存相同的代码结构,但应用随机标记?