有一种更优雅和正确的方法。不要忘记可用性。而且跳过冒号,那不是纸质表格!
form(name="input", action="html_form_action.asp", method="get")
key Username
input(type="text", name="user")
key Password
input(type="password", name="pswd")
input(type="submit", value="Submit")
我正在使用mixin来进行表单渲染,这使得我的代码具有可重用性和灵活性。请看这里:
mixin text(name, value, title)
key=title
input(type="text" name=name value=value)
mixin password(name, value, title)
key=title
input(type="password" name=name value=value)
mixin submit(name, value)
input(type="submit" name=name value=value)
form(name="input", action="html_form_action.asp", method="post")
mixin text('user', null, 'User')
mixin password('pswd', null, 'Password')
mixin submit('do', 'Login')