简体   繁体   English

什么!在玉/哈巴狗做什么?

[英]What does != do in jade/pug?

How does != work in jade code below.. != messages() 怎么做!=在下面的玉代码中工作.. != messages()

extends layout

block content
 .spacer
 .container
  .row
   .col-lg-8.col-lg-offset-2.col-md-10.col-md-offset-1
    a(class='btn btn-tiny btn-primary' href='/manage/categories/add') Create Category
    h1= title
     small
      a(href='/manage/articles')  Manage Articles
    != messages()
    table(class='table table-striped')
     tr
      th Category Title
      th
     each category, i in categories
      tr
       td #{category.title}
       td 
        a(class="btn btn-tiny btn-default" href="/manage/categories/edit/#{category._id}") Edit

app.js app.js

app.use(require('connect-flash')());
app.use(function (req, res, next) {
  res.locals.messages = require('express-messages')(req, res);
  next();
});

It is called "interpolation". 它被称为“插值”。

It means that "messages()" is escaped, eg if you have following code: 这意味着“messages()”被转义,例如,如果您有以下代码:

var randomText = '<p> this is a <strong>text</strong></p>'
p= randomText

which would normally, unescaped, produce just what it is: 通常,未转义的,产生的就是它:

'<p> this is a <strong>text</strong></p>'

but if I typed this: 但如果我打字:

p!= randomText

it would actually became ap tag, looking exactly like this: 它实际上会成为ap标签,看起来完全像这样:

this is a text 这是一篇文章

Hope it helps you :-) 希望它可以帮助你:-)

You can read more about in the documentation, here: https://pugjs.org/language/interpolation.html 您可以在文档中阅读更多信息,请访问: https//pugjs.org/language/interpolation.html

you should try 你应该试试

if(!messages())
 table(class='table table-striped')

you have to assign some value into left hand side. 你必须在左侧分配一些值。 otherwise just validate into if condition. 否则只是验证if条件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM