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
2 answers

express, jade, node.js, coffeescript, setting up routes using an array of variables and a for loop

I just inherited a project with node.js/express written in coffeescript and using jade to render views. In my views folder I have about 20 jade files that need to have routes set up. Rather than repeat myself over and over like so (which is…
satyrsynth
  • 399
  • 1
  • 4
  • 14
2
votes
1 answer

What is output buffering in node?

I'm programming in node.js using the express framework. The default template engine in express is Jade. In the Jade specification there is a concept mentioned called output buffering. What exactly is happening when I use this?
CatDadCode
  • 58,507
  • 61
  • 212
  • 318
2
votes
1 answer

Simpler, Cleaner Inline Links [JADE Preprocessing]

I wish to write the following simple html in Jade:

Nevertheless, you can read his stuff on his nameless blog as well as on the Voice college blog.

An ugly, long, error-prone way of doing this is: p…
daba
  • 157
  • 3
  • 14
2
votes
1 answer

Railway.js + Jade crashes when a route to '/client' is defined

I get this weird error when I add a route '/client' in Railway.js: 500 ReferenceError: jade is not defined I get this for any valid route in my app, not only '/client'. This line seems to be added to the top of my Jade compiled templates, and is…
emilecantin
  • 286
  • 3
  • 9
2
votes
1 answer

Backbone.js - Modify already rendered page

I'm trying to learn the jade template system and backbone.js in the context of a (relatively simple) node.js webapp. I'm using express.js as my framework. Anyway, backbone.js looks really interesting and powerful, but I don't want to render my…
mschallert
  • 4,129
  • 2
  • 17
  • 10
2
votes
1 answer

Parser skips lines

I want to write a simple parser for a subset of Jade, generating some XmlHtml for further processing. The parser is quite simple, but as often with Parsec, a bit long. Since I don't know if I am allowed to make such long code posts, I have the full…
Lanbo
  • 15,118
  • 16
  • 70
  • 147
2
votes
1 answer

How to include Javascript objects in a Jade template before Jade compilation

I am working with a website built with Jade/Express for a few weeks now. I recently organized the image folder for the website so all the images were disbursed between several folders to make it easier to use and sort through. To make it easier to…
2
votes
1 answer

Dynamic width of an element in jade

I am trying to design a progress bar and I want to try to set the width of the bar depending on some mathematical calculations. Below is working fine, since I am hardcoding the width to 60% .pledged(style="width:60%") I want to do something like…
Prashant
  • 23
  • 4
2
votes
2 answers

Return mongojs query result from function

I made the function below for getting usernames from ids. It is not working well. I can write console.log(result.first_name); within the query function, and the usernames shows up in my terminal, but not the browser. I tried adding “return…
Frode
  • 501
  • 2
  • 7
  • 20
2
votes
3 answers

Returned object is undefined, using dynamicHelpers

I've created an external file that's handling the dynamic helpers, which includes a bunch of functions that I want to be able to use from all my views. In on of the functions I'm running a query and fetch tags from the database, which I want to use…
holyredbeard
  • 19,619
  • 32
  • 105
  • 171
2
votes
1 answer

Jade thinking mixin is undefined, but it's not

Why this doesn't work? extends layout mixin WhyNotDefined(text) p #{text} append content mixin WhyNotDefined('Hi') I keep getting error: WhyNotDefined_mixin is not defined jade@0.20.3; node v0.6.14 upd. Stupid of me, mixins should be defined…
Aleksei Zabrodskii
  • 2,220
  • 3
  • 19
  • 41
1
vote
1 answer

loading google charts in jade

I'm trying to load a google annotated chart using jade but can't get the chart to render. I was able to get a pie chart to load, but can't when loading a chart that needs the container element size to be specified explicitly. The example from google…
tal
  • 11
  • 2
1
vote
3 answers

Why won't the `email` property of my json object display in my jade template?

Having the strangest problem. I can't display the email property of an object. I'm using Mongoose/Express/Jade. I'm doing a: User.find({ _id : { $in : req.project.subscribers } } , function (err, subs){... Which works just fine and returns a list…
k00k
  • 17,314
  • 13
  • 59
  • 86
1
vote
1 answer

can jade display a new value without refreshing the page?

app.get('/', function (req, res) { res.render('home.jade', { results: req.session.value }); }); What i would like know is whether i can use jade to display req.session.value in the html when it has been given a value after i have…
Aldon Palmer
  • 182
  • 2
  • 12
1
vote
1 answer

Twitter bootstrap two column rendering in jade?

I know how to make the blocks look in bootrstrap but i dont know how to make it in jade. The structure should look like this // Input for post in posts // Output should be this div.row /// Looped from each div.span6 ..More content POST 1 …
Risto Novik
  • 8,199
  • 9
  • 50
  • 66
1 2 3
99
100