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
76
votes
4 answers

How to use the style tag with jade templates?

This style code worked for me a few months back. I have updated to the latest Jade NPM package and now it is not working. Can some please assist me with the proper way to inline a style in a Jade template? doctype 5 html(lang="en") head …
MobileGuy
  • 1,232
  • 1
  • 11
  • 21
70
votes
5 answers

Accessing Express.js local variables in client side JavaScript

Curious if I'm doing this right and if not how you guys would approach this. I have a Jade template that needs to render some data retrieved from a MongoDB database and I also need to have access to that data inside a client side JavaScript…
braitsch
  • 14,906
  • 5
  • 42
  • 37
66
votes
4 answers

Change value of input placeholder via model?

I'm trying to change the value of the input placeholder from a controller but cant quite figure out how. input(type='text', ng-model='inputText', side='30', placeholder='enter username') Is there a way to modify a model's element attributes?
Jonah Katz
  • 5,230
  • 16
  • 67
  • 90
66
votes
2 answers

Rendering HTML in variable using Jade

I have some text stored in a variable which contains some HTML. For example, the cat in the hat. However, when I render it in Jade, it shows up with the tags instead of rendering the formatting. How can I fix this?
tofutim
  • 22,664
  • 20
  • 87
  • 148
62
votes
3 answers

What is a concise way to create inline elements in Jade

I like to put all my inline elements in a single line.
  • clickhere!
  • Wondering if there's a better way to create inline elements in Jade than this: ul li a(href="#") click span here …
jwerre
  • 9,179
  • 9
  • 60
  • 69
59
votes
4 answers

Jade: How to include a javascript file

I need to include a javascript file to webpage. I write the following: include /../scripts/jquery.timeago.js but I get