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
1
vote
1 answer

How can I serve an index.jade?

I'm using express, and writing my views in jade. One of them is an index.jade file, id like to serve this file as you would an .html. How would I do this? I tried res.sendfile('views/index.jade') and res.sendfile('views/index.html') Thanks!
fancy
  • 48,619
  • 62
  • 153
  • 231
1
vote
1 answer

How do I render a nested data structure with Node.js/Jade

In my .js file I have the following data structure var menu = { "Sport":"Racing", "Region":{ "AUS":{ "name":"APrk", "key":"1234" }, "GB":{ "name":"Cran", "key":"5678" } } }; res.render('layout.jade', {locals: {menu:…
Hoa
  • 19,858
  • 28
  • 78
  • 107
1
vote
1 answer

Jade variable rendering inside tag specifications

I have a Jade page like so: table th Site Name th Deadline th Delete Transaction - if (transactions != null) each item in transactions tr td= item.item_name td …
Masiar
  • 20,450
  • 31
  • 97
  • 140
1
vote
2 answers

thumbnail image rendering through node.js

My app requires lot of thumbnail images to be rendered and I usually render 20 each page.. It's a live scroll and it works fine. I mean I do not see any delay in loading the images. I'm using express, jade, gzippo (for compression).. In one page…
user644745
  • 5,673
  • 9
  • 54
  • 80
1
vote
1 answer

express jade upgrade to latest throwing error

My app was running fine with express, jade etc. Today when I upgraded this to latest express and jade, using npm update express jade, it started throwing the following error when i try to access the site. Is it expecting a package.json ? I am not…
user644745
  • 5,673
  • 9
  • 54
  • 80
1
vote
2 answers

Accessing jQuery object in JADE

During login, I save the userId in a jQuery cookie, so that I can access it by $.cookie('userId'). Now that I am trying to access it from Jade, as, - if ($.cookie('userId') === userId) I get an error $ is not defined How can I access the cookie…
user644745
  • 5,673
  • 9
  • 54
  • 80
1
vote
2 answers

How do I output Jade content through JSON? (Node.js)

I wrote a video gallery web app a few months ago in CodeIgniter and I'm trying to move the back end to Node, using Express + Jade to produce the content. The PHP version sends JSON to the front end, often including a substantial chunk of HTML. I'd…
meloncholy
  • 2,122
  • 18
  • 16
1
vote
1 answer

Custom Attributes for Buttons in jade

Hi I'm trying to code a webpage using node.js and jade. I'm trying to add a custom attribute to a button, like in HTML: where someSpecialID is a value passed into…
Benedict Lee
  • 714
  • 8
  • 21
1
vote
2 answers

Jade-lang add manifest file

I would like to know how to add the manifest file to node.js site with jade-lang and express. I found this as an issue 239 in github. My question is how can I add some data into the buffer without while we wait for the resolution of the…
enedebe
  • 268
  • 1
  • 5
  • 15
1
vote
1 answer

Include the contents of other files when rendering jade in Express?

I have the following layout.jade: !!! html head title= title link(rel='stylesheet', href='/stylesheets/style.css') body!= body In the body, I'd like to include the contents of another file, content.jade. I'm trying something like this…
ario
  • 1,727
  • 4
  • 19
  • 28
1
vote
1 answer

Jade template inheritance

Jade template inheritance in Jade is driving me mad... The problem is that I would like to exclude a large bit of code to external template and then include it. When I do so everything gets f** up :/ Sample code: !!!5 html(lang="en") head …
Pono
  • 11,298
  • 9
  • 53
  • 70
1
vote
1 answer

Express Url Generation

I've recently been playing with nodejs and would like to build my first project with it. But there is a major stumbling block for me. URL Generation. I'm very used to Codeigniter's base_url() and site_url(), this gave a full url like…
Johann du Toit
  • 2,609
  • 2
  • 16
  • 31
1
vote
1 answer

nodejs jade issue

I my jade view I give the array 'arr': server.js app('/', function (req, res) { res.render('index', { arr: [1,2,3] }); }); I my index view I need to make something like this: index.jade: - if (arr && arr.length) { for (var i=0;…
Erik
  • 14,060
  • 49
  • 132
  • 218
1
vote
1 answer

How do I get a variable by name in a mixin

Form (partial): include ../mixins/form-helpers form(action='/users/create', method='post') div.fields fieldset mixin field('text', 'email', 'Email') mixin field('password', 'password', 'Password') mixin field('password',…
Pickels
  • 33,902
  • 26
  • 118
  • 178
1
vote
1 answer

Express: 500 ReferenceError not definied error

I have app.js with following code: var express = require('express') , siteVersion = require('./lib/helpers.js').siteVersion; helpers.js: exports.helpers = { siteVersion: function(name, version) { return…
user1145952
  • 61
  • 1
  • 3
1 2 3
99
100