Questions tagged [pug]

Pug (formerly known as Jade) is a robust, elegant and feature-rich template engine for Node.js.

Pug (formerly Jade) is a clean, whitespace-sensitive syntax for writing HTML. Here is a simple example:

doctype html
html(lang="en")
  head
    title= pageTitle
    - if (foo) bar(1 + 5)
  body
    h1 Pug - node template engine
    #container.col
      if youAreUsingPug
        p You are amazing
      else
        p Get on it!
      p.
        Pug is a terse and simple templating language with a
        strong focus on performance and powerful features.

Produces following output as HTML:

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

Links

6377 questions
2
votes
1 answer

TypeError while compiling Jade template

I have this jade template that started causing the following TypeError. TypeError: /home/jared/code/fiestah-admin/views/items.jade:11 9| a(href=urlFor('item details', { 10| params: { \> 11| //id:…
Jared
  • 2,043
  • 5
  • 33
  • 63
2
votes
1 answer

Jade shortcut for writing lists

Is there a way to drop the need for ol and ul in jade lists - I want to write... ol first item li second item li third item seems like too much indenting otherwise Currently, I am thinking I could make a filter that wraps each line with
  • |
  • Billy Moon
    • 57,113
    • 24
    • 136
    • 237
    2
    votes
    1 answer

    Express image upload and view in jade

    I'm trying to upload an image and show it in express. I configured my app to upload in 'public/images' app.use(express.bodyParser({ keepExtensions: true, uploadDir: './public/images' })); The upload goes great but I can't find how to show…
    Secco Jones
    • 163
    • 5
    • 16
    2
    votes
    1 answer

    Setting global res.local variables on each request in express.js

    Basically I want to build a site wide navigation bar that contains links as specified in the local variables in express.js So I build my list of links I want to include on a page: class NavigationLink constructor: (@title,@url) -> app.use…
    Msencenb
    • 5,675
    • 11
    • 52
    • 84
    2
    votes
    1 answer

    How can I escape code in a Jade template filter, without single-quotes?

    I'm using the CoffeeScript filter in Jade on Node.js because I need to insert it into the contents of the script tag I'm generating. I can do this using: :coffeescript myNum = '#{locals.myNum}' On the server, locals.myNum is a number, but I have…
    zfogg
    • 455
    • 5
    • 22
    2
    votes
    1 answer

    Jade URL Routing in Node Express

    I am building a Node Express application using Jade, and I am confused about how to route my views to the specific requests the browser will make. I understand that in order to get URLs to work in the browser, we need to use Node's routes; however,…
    user1429980
    • 6,872
    • 2
    • 43
    • 53
    2
    votes
    1 answer

    Conditional Include in Jade + Express

    How can one use if -else statement on "include" in jade?? For example, if I have two separate navigation bar templates navbar.jade and navbar_notloggedin.jade I would like to do: input(type='hidden', value= user.user)#username - if(user.user!="") …
    user1583920
    • 227
    • 4
    • 11
    2
    votes
    1 answer

    How to use Ember.js {{action}} in Handlebars.js templates on top of Jade

    I'm using Ember.js and Handlebars.js for a project I'm working on at the moment. Server-side is Node.js + express and I make use of the Jade templating engine. Now, whenever I want to tie actions to DOM elements, I use the {{action}} attribute of…
    Kasper Tidemann
    • 488
    • 1
    • 3
    • 15
    2
    votes
    3 answers

    Node.js, Express, Jade - Error: Can't set headers after they are sent

    I'm getting the following error when trying to produce an HTML page using Jade. Has anybody else experienced this issue. I noted below where exactly the error is caused. Error Error: Can't set headers after they are sent. at…
    Apollo
    • 8,874
    • 32
    • 104
    • 192
    2
    votes
    2 answers

    template inheritance with Express and Jade

    I'm having difficulty getting template inheritance to work properly. I'm finding that I can get index/layout working well, but that it's not including other extended blocks. For example, here's my layout.jade file: #wrapper block tester …
    bento
    • 4,846
    • 8
    • 41
    • 59
    2
    votes
    2 answers

    Vundle: activate Jade highlighting?

    Mac OSX 10.7, Vim 7.3 I have installed Vundle for Vim, and I have included these lines in my ~/.vimrc: Bundle "gmarik/vundle" Bundle "pangloss/vim-javascript" Bundle "https://github.com/digitaltoad/vim-jade.git" I then run (in Vim):…
    allanberry
    • 7,325
    • 6
    • 42
    • 71
    2
    votes
    4 answers

    How to best organize Underscore.js templates for use with Backbone.js?

    Currently I have my main.jade file which is served using Express.js on Node.js. In the head of the jade file, I have all of my templates. As you can probably understand, this got unruly very quickly. I load the templates from Backbone.js…
    Sam P
    • 1,821
    • 13
    • 26
    2
    votes
    1 answer

    Jade dynamic data

    Using node.js I am passing some variables to jade view: res.render('index', { locals: { name: user.name, hashpassword: JSON.stringify(user.hashPass), languages:…
    misaizdaleka
    • 1,776
    • 3
    • 21
    • 32
    2
    votes
    2 answers

    Express Error: EMFILE, too many open files

    I am getting the following very annoying error: Error: EMFILE, too many open files '/home/savagegames.net/views/index.jade' at Object.openSync (fs.js:240:18) at Object.readFileSync (fs.js:128:15) at View.contents…
    Ian Macalinao
    • 1,608
    • 3
    • 20
    • 30
    2
    votes
    1 answer

    Jade - Unexpected Identifier

    I use the following NodeJS route: server.get('/', function(req, res) { res.render('index'); }); it seems that I have an error in my index.jade file, since it tells me: SyntaxError: Unexpected identifier at Object.Function (unknown source) …
    Michael Kohler
    • 753
    • 10
    • 22