将if / else语句添加到Pug(ex-Jade)mixins中?

时间:2016-04-18 15:00:03

标签: html pug pugjs

如何将mix / else语句添加到mixin以将checked属性添加到我的第一个无线电输入?

mixin tab-header(name, id)
  input(type='radio' name='tabs' id=id checked)
  label(for=id) name
+tab-header('Monday', 'toggle-monday')
+tab-header('Tuesday', 'toggle-tuesday')
+tab-header('Wednesday', 'toggle-wednesday')
+tab-header('Thursday', 'toggle-thursday')

1 个答案:

答案 0 :(得分:1)

只需添加一个参数:

mixin tab-header(name, id, checked)
  input(type='radio' name='tabs' id=id checked=checked)
  label(for=id) name

+tab-header('Monday', 'toggle-monday', true)