[英]Dynamic element in Jade with String and a variable
I have a variable for example named "elem" , "elem" may be head, body and foot; 我有一个变量,例如名为“ elem”,“ elem”可以是头部,身体和脚;
I want to create html element with for example; 我想用例如创建html元素;
if elem == "body"
"t" + elem => tbody html element
if elem == "head"
"t" + elem => thead html element
if elem == "foot"
"t" + elem => tfoot element
I tried many combination but not able to that. 我尝试了许多组合,但未能做到这一点。 How can implement this case?
如何实施这种情况?
Try something like this (I assume elem = "foot"
in this case): 尝试这样的事情(在这种情况下,我假设
elem = "foot"
):
- var tag = "t" + elem;
table
thead
tbody
#{tag}
should render: 应该呈现:
<table>
<thead></thead>
<tbody></tbody>
<tfoot></tfoot>
</table>
But keep in mind this table is not html conform. 但是请记住,此表不是html符合。 It's just for demonstration.
这只是为了演示。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.