Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/38.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 如何在jade模板中使用HTML语法_Node.js_Pug - Fatal编程技术网

Node.js 如何在jade模板中使用HTML语法

Node.js 如何在jade模板中使用HTML语法,node.js,pug,Node.js,Pug,我想重点学习如何在节点中构建东西,而不必费心处理jade语法。我想知道是否有可能在jade模板中混合原生html语法及其循环语法等。如果有,如何混合。如果没有,是否有允许此操作的节点模板引擎 谢谢。当然,您可以将普通HTML和Jade代码混合在一起,只需使用。 例如: | <a href="#">Plain HTML</a> 生成以下代码: <!DOCTYPE html> <html lang="en"> <head> &

我想重点学习如何在节点中构建东西,而不必费心处理jade语法。我想知道是否有可能在jade模板中混合原生html语法及其循环语法等。如果有,如何混合。如果没有,是否有允许此操作的节点模板引擎


谢谢。

当然,您可以将普通HTML和Jade代码混合在一起,只需使用。
例如:

| <a href="#">Plain HTML</a>
生成以下代码:

<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Jade Demo</title>
    <script type="text/javascript">
      if (foo) {
         bar(1 + 5)
      }
    </script>
  </head>
  <body>
    <h1>Jade - node template engine</h1>
    <div id="container" class="col">
      <p>You are amazing</p>
      <p>
        Jade is a terse and simple
        templating language with a
        strong focus on performance
        and powerful features.
      </p>
    </div><a href="#">Plain HTML</a>
  </body>
</html>

翡翠演示
如果(foo){
巴(1+5)
}
Jade节点模板引擎
你太棒了

玉是一种简洁而简单的颜色 使用 高度关注绩效 功能强大。


您看过EJS吗?谢谢你。我想我在某个地方读到了类似的东西,我想有人会知道的。在什么文件中应该放“测试数据”?app.js?我正在传递您正在使用的jade:正确,但jade模板仍然认为它是错误的。
{
  pageTitle: 'Jade Demo',
  youAreUsingJade: true
}
<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Jade Demo</title>
    <script type="text/javascript">
      if (foo) {
         bar(1 + 5)
      }
    </script>
  </head>
  <body>
    <h1>Jade - node template engine</h1>
    <div id="container" class="col">
      <p>You are amazing</p>
      <p>
        Jade is a terse and simple
        templating language with a
        strong focus on performance
        and powerful features.
      </p>
    </div><a href="#">Plain HTML</a>
  </body>
</html>