HTML to Jade 帮助

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7054239/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 10:03:27  来源:igfitidea点击:

HTML to Jade help

htmlnode.jsexpresspug

提问by Sahat Yalkabov

I am trying to create a simple form with 2 input fields and 1 button.

我正在尝试创建一个带有 2 个输入字段和 1 个按钮的简单表单。

Here's HTML that needs to be translated to Jade:

这是需要转换为 Jade 的 HTML:

<form name="input" action="html_form_action.asp" method="get">
  Username: <input type="text" name="user" />
  Password: <input type="text" name="pswd" />
  <input type="submit" value="Submit" />
</form>

Please help me before I throw this computer out of the window and send a kill squad after Jade templating language developers.

在我把这台电脑扔出窗外之前,请帮助我,并在 Jade 模板语言开发人员之后发送一个杀戮小队。

回答by Alex Wayne

form(name="input", action="html_form_action.asp", method="get")
  | Username:
  input(type="text", name="user")

  | Password:
  input(type="text", name="pswd")

  input(type="submit", value="Submit")

回答by Paul Rumkin

There is more elegant and correct way. Don't forget about usability. And skip colons it's not a paper form!

还有更优雅更正确的方式。不要忘记可用性。并跳过冒号,这不是纸质表格!

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")

For form rendering I'm using mixins. It makes my code reusable and flexible. Look here:

对于表单渲染,我正在使用 mixins。它使我的代码可重用且灵活。看这里:

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')

回答by NeonNinja

I recently noticed on the Jade github page a link was added for a HTML to Jade converter:

我最近注意到在 Jade github 页面上添加了一个链接,用于 HTML 到 Jade 转换器:

https://github.com/donpark/html2jade

https://github.com/donpark/html2jade

Might be worth checking out, rather than hand translating if you've got more than a few to convert.

如果您有多个要转换的内容,则可能值得一试,而不是手动翻译。

回答by Hyman

You can use plain HTML in a Jade document and it will render correctly (Just incase you ever need to use it!)

您可以在 Jade 文档中使用纯 HTML,它会正确呈现(以防万一您需要使用它!)

回答by Madhukarah

There are many online HTML to JADE converts. Here is a good one.

有许多在线 HTML 到 JADE 的转换。这是一个很好的。

HTML to Jade converter

HTML 到 Jade 转换器