Questions tagged [pugjs]

pugjs is the Github organization which creates the "Pug" (previously known as "Jade") Node.js templating library.

Organization link: https://github.com/pugjs

79 questions
40
votes
5 answers

pugjs(jade) template engine loading css file

I've been searching in the examples on the GitHub but I couldn't find how to load a simple css file into my layout. My first thought was doing something like this link(href="my.css") but it seems it's not working at all. The href points to a correct…
Masiar
  • 20,450
  • 31
  • 97
  • 140
22
votes
15 answers

Error: Cannot find module 'pug'

Here is my index.js file: const express = require('express') const app = express() app.set('views', __dirname + '/views'); app.set('view engine', 'pug') app.get('/', function (req, res) { res.render('index', { title: 'Hey', message: 'Hello…
Harsh Patel
  • 6,334
  • 10
  • 40
  • 73
17
votes
2 answers

How to pass an object from pug to front end javascript

I´m using pug and I want to pass a variable to the front end for information, but when I´m trying to do that it pass like a text. This is how I do that. Controller code: res.render('view/edit', { title: 'Title', sub:true, data:…
Jorge Mejia
  • 1,153
  • 1
  • 10
  • 27
16
votes
1 answer

Pug (formerly Jade) Variables Not Working (Interpolating) Correctly Inside Anchor Href

I'm playing around with Node and Express and I'm using the Pug (formerly Jade) templating engine to render my html. Everything has been working fine up until I started trying to inject variables into the href of my anchor links. Whats odd is that if…
Corey
  • 481
  • 2
  • 5
  • 11
12
votes
1 answer

How to console.log in pug?

How can I console.log the data coming from the backend in pug? For instance, this is my backend in expressjs: res.render("streams/show", { stream: cleanStream }); in show.pug, I want to inspect the data from steam: - var species =…
Run
  • 54,938
  • 169
  • 450
  • 748
9
votes
2 answers

Save jwt to local storage

I'm currently developing a node express postgresql application, and I'm trying to implement Jsonwebtokens as authentication. I've seen multiple tutorials on how to implement it and I get how to do it on the backend part, but the frontend is usually…
7
votes
1 answer

jade/pug Is it possible to use variables on include statement?

I'm developing nodejs application and I have issue with include statement. It works when I use it like this: include ../mixins/root.pug ...but is it possible to use variables on include? None of these work: include…
EspeH
  • 1,308
  • 2
  • 16
  • 34
6
votes
2 answers

Multiline variables in Pug (ex-Jade)

Is it possible to use it? For example here: - var movieList = [{title: "Ocean's Eleven", rating: 9.2}, {title: "Pirates of the Caribbean", rating: 9.7}]; mixin movie-card(movie) h2.movie-title= movie.title div.rating p= movie.rating for…
Entry Guy
  • 425
  • 1
  • 7
  • 18
5
votes
1 answer

Pug dynamic image src interpolation

I have stored a dynamic url link into a pug variable #{img}. Now I want to include that variable into my image element. Can anyone help me fill in the blank? #{img} //some dynamic url img(src=" ") //want to set src = #{img}
David
  • 303
  • 3
  • 8
  • 21
5
votes
1 answer

Unexpected token "indent" when using Pug templates

I have a simple application that should output a small content. I use NodeJs, Express and Pug. const pug = require('pug'); const express = require('express'); const app = express(); const indexFile = 'index'; // the file to load app.set('view…
peterHasemann
  • 1,550
  • 4
  • 24
  • 56
5
votes
3 answers

external style sheet in pug template will not load

I am unable to figure out how to get a style sheet to load in pug. I have tried every which way I can think of. and have searched extensively on Google. This seems like such a silly problem, but I have already wasted so much time trying to figure it…
Riley Hughes
  • 1,344
  • 2
  • 12
  • 22
5
votes
1 answer

HTML link with data-method isn't working

Im trying to create a link in a view of AngularJS application just to send a data-method DELETE. My route: app.delete('/logout', function(req, res) { req.session = null res.status(200) res.redirect('/') }) My PugJS…
JonatasTeixeira
  • 1,474
  • 1
  • 18
  • 24
5
votes
1 answer

How to add a space character between two

Input: .a text1 .b text2 Output will be:
text1
text2
The second
is just close to the first one without any spaces or LFs. However, this is what I really want to get:
text1
AGamePlayer
  • 7,404
  • 19
  • 62
  • 119
4
votes
0 answers

hexo, pug: howto create pug content that uses a pug layout from the theme

How can I move blocks from pug templates in source into pug templates in a theme? New to hexo. Working on a hexo-theme-bootstrap4-starterkit theme. Made some pug template using pug -w index.pug. Trying to move my content out of…
Michael Cole
  • 15,473
  • 7
  • 79
  • 96
4
votes
1 answer

pugJS passing a variable to a mixin in a loop

Trying to loop over some html based on how many questions there are while using a mixin. I'm expecting that this code would loop over the div 3 times and pass each question into the mixins of input-label and input-field and spit out the proper html…
KKendle
  • 61
  • 4
1
2 3 4 5 6