[英]Can I create dynamic variable names in jade using an array of string values for an object?
[英]Dynamic element in Jade with String and a variable
我有一个变量,例如名为“ elem”,“ elem”可以是头部,身体和脚;
我想用例如创建html元素;
if elem == "body"
"t" + elem => tbody html element
if elem == "head"
"t" + elem => thead html element
if elem == "foot"
"t" + elem => tfoot element
我尝试了许多组合,但未能做到这一点。 如何实施这种情况?
尝试这样的事情(在这种情况下,我假设elem = "foot"
):
- var tag = "t" + elem;
table
thead
tbody
#{tag}
应该呈现:
<table>
<thead></thead>
<tbody></tbody>
<tfoot></tfoot>
</table>
但是请记住,此表不是html符合。 这只是为了演示。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.