Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does != do in jade/pug?

How does != work in jade code below.. != 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.use(require('connect-flash')());
app.use(function (req, res, next) {
  res.locals.messages = require('express-messages')(req, res);
  next();
});
like image 908
CodeCrack Avatar asked Jun 18 '16 04:06

CodeCrack


1 Answers

It is called "interpolation".

It means that "messages()" is escaped, e.g. if you have following code:

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 a p tag, looking exactly like this:

this is a text

Hope it helps you :-)

You can read more about in the documentation, here: https://pugjs.org/language/interpolation.html

like image 151
Daniel Avatar answered Nov 15 '22 04:11

Daniel