在Python,反覆給我一個命名的變量:如何在ractive.js中獲得一個命名的循環變量?
for cage in cages:
for animal in cage.animals:
print("The current cage is",cage)
print("the current animal is",animal)
在Ractive模板,我似乎沒有能夠做到這一點。
{{#cages}}
{{#animals}}
The current animal is {{.}} or {{this}},
but I don't know how to refer to the current cage,
i.e. the outer loop variable
I would like to be able to say {{cage}} has an {{animal}}
{{/animals}}
{{/cages}}
有沒有我不知道的語法?
我非常希望看到'{{#each cage in cage}}或'{{#each cages as cage}}',這會使編寫嵌套循環變得更容易。 – trvrm