帕格/玉 – input是一个自闭元素:<input />但包含嵌套的内容?

我想创build这样的HTML:

<label class="radio-inline"> <input type="radio" name="hidden" checked="" value="Visible"> Visible </label> 

帕格/玉:

 label.radio-inline input(type="radio", name="hidden", value="0", checked="") Visible 

但是我得到一个错误:

input是一个自我closures的元素:但包含嵌套的内容。

这是什么意思? 我如何解决这个问题?

使用Jade / Pug有多种方法。 第一种方法是使用pipe道字符(需要换行):

 input | text 

第二种方法是使用标签插值(并且可以保持在同一行):

 #[input] text 

所以Jethro的另一个答案是:

 label.radio-inline #[input(type='radio', name='hidden', value=0, checked='')] Visible 

请注意,你甚至可以这样做:

  label #[input] text 

这将产生:

 <label> <input/> text </label> 

你需要这样的:

 label.radio-inline input(type='radio', name='hidden', value=0, checked='') | Visible 

放在与input相同的行上,使得哈巴狗将其解释为input元素的内部HTML。

我认为将input放在label标签中是没有意义的,或者不是? 你可以做

 label(for="ya") Visible input(id="ya", type="radio", name="hidden", value=0, checked="") 

这给你一个符合现代networking标准的完美标签的单选button。