pug

Express: why is this GET request executed twice?

谁说我不能喝 提交于 2020-05-13 14:24:27
问题 I have some code written in Jade, with a link in it. The destination of the link is generated by Jade. When the link is clicked, I notice from my console that the GET-request is being executed twice. Why is this? How can I fix this? Here is my code: Jade file: ul.media-list each paper in paperList div.panel.panel-default div.panel-body li.media div.media-left.media-middle a(href='/publication/view/#{paper.id}') | Some image div.media-body div.btn-group(role='group') //!!! When this link is

How to persist user data after refreshing the page?

百般思念 提交于 2020-04-18 04:38:58
问题 I have couple of check boxes and input fields. When any of them are checked or any value entered to the input fields, I need to persist these data even after refreshing or URL location change.Can someone help me? 回答1: You can use localStorage of HTML5 http://www.w3schools.com/html/html5_webstorage.asp 回答2: Use cookies, they are the most reliable way to save data across browsers, also you can later access it server side. If you don't need expiration or advanced functionality you can use the

Pug/Jade interpolation not working for attributes

假如想象 提交于 2020-04-17 23:02:38
问题 I have a page which I am rendering like this: res.render('account.pug', {user: req.user._id}) —and which is supposed to show a profile picture which corresponds to the user like this: img(id='profilepicture' src='profilepictures/#{user}') However, the Pug renders as: <img id='profilepicture' src='profilepictures/#{users}' /> —instead of: <img id='profilepicture' src='profilepictures/USERID' /> —so the correct profile picture does not display. It is weird because when I write div #{user} it

Pug/Jade interpolation not working for attributes

a 夏天 提交于 2020-04-17 23:02:03
问题 I have a page which I am rendering like this: res.render('account.pug', {user: req.user._id}) —and which is supposed to show a profile picture which corresponds to the user like this: img(id='profilepicture' src='profilepictures/#{user}') However, the Pug renders as: <img id='profilepicture' src='profilepictures/#{users}' /> —instead of: <img id='profilepicture' src='profilepictures/USERID' /> —so the correct profile picture does not display. It is weird because when I write div #{user} it

Dynamic locals unavailable with Pug and Parcel

只愿长相守 提交于 2020-04-13 18:04:38
问题 I have an Express app using Pug templates and Parcel for my bundler. According to the Parcel docs, I can have a config file that stores my locals pug.config.js , however, I need to dynamically add locals to my templates at runtime. Is it possible to do this? Here are my files: index.pug ... h1 #{isAuthenticated} h1 #{env} ... pug.config.js module.exports = { locals: { env: process.env.NODE_ENV } } app.js const Bundler = require('parcel-bundler') const bundler = new Bundler(path.resolve(_

Dynamic locals unavailable with Pug and Parcel

独自空忆成欢 提交于 2020-04-13 18:03:32
问题 I have an Express app using Pug templates and Parcel for my bundler. According to the Parcel docs, I can have a config file that stores my locals pug.config.js , however, I need to dynamically add locals to my templates at runtime. Is it possible to do this? Here are my files: index.pug ... h1 #{isAuthenticated} h1 #{env} ... pug.config.js module.exports = { locals: { env: process.env.NODE_ENV } } app.js const Bundler = require('parcel-bundler') const bundler = new Bundler(path.resolve(_

How to reference layout images in express.js so that they can be found from nested directories?

人盡茶涼 提交于 2020-03-26 07:20:13
问题 I've got an express.js app currently using ejs (using jade for newer projects) and I'm trying to solve a problem in a clean and appropriate manner. I've got a layout.ejs file with my header and footer in it. Most of my site so far has been one layer deep http://innovationbound.com/about or /services or /amy and so on.... I'm beginning to created online courses at http://innovationbound.com/courses/course-name and the issue I'm having is that these course pages can't reference the images the

How to use script. in JADE templates

风格不统一 提交于 2020-03-22 08:20:40
问题 I have created a simple node app using the express framework using JADE templating. All was well in the learning process until I came to try and run some client-side js which I cannot figure out how to do. Is there something I need to do in my app/index.js to tell node about them? Any help would be much appreciated. Thanks index.jade extends layout block content h1 Title script. console.log("I am running on the client"); app.js var http = require("http") var express = require("express") var

How to use script. in JADE templates

为君一笑 提交于 2020-03-22 08:20:11
问题 I have created a simple node app using the express framework using JADE templating. All was well in the learning process until I came to try and run some client-side js which I cannot figure out how to do. Is there something I need to do in my app/index.js to tell node about them? Any help would be much appreciated. Thanks index.jade extends layout block content h1 Title script. console.log("I am running on the client"); app.js var http = require("http") var express = require("express") var

How to trigger a new line in jade/pug?

对着背影说爱祢 提交于 2020-03-03 18:26:11
问题 I want to write several object attributes in a singular table tab each on a new line here's my pug table code excerpt table#posts(style="float:right; border: 1px solid green") tbody each post in data tr td(style="border: 1px solid green")='Name: ' + post.firstname + ' ' + post.lastname + 'Date of Birth: ' + post.dob td(style="border: 1px solid green") buttons else tr td No posts! I want the new line to be between the Name and date of birth. Any help is appreciated, thank you! 回答1: Add a <br /