pug

node res.render changes view but not url

本秂侑毒 提交于 2021-01-28 18:59:57
问题 I am sending an id from a jade view to its controller (backend), the controller then queries mongodb and the result is sent to a new jade view - angular . The results & view appear but URL stays the same (previous view), thus if I F5 the current view, it reloads the previous view. So the route is: view->node->angular Ideas? jade launcher view form(method="post") input(type="hidden" name="id" value=cart._id) input(type='hidden', name='_csrf', value=_csrf) button.btn.product.btn-primary(type=

Mixin declared without body

一曲冷凌霜 提交于 2021-01-28 06:42:06
问题 I am doing the Wes-bos Learn node course.I am on the part of saving stores and using mixins. When I write mixins and run my app it gives this error. Error: C:\Users\ATUL\Downloads\Learn-Node-master\Learn-Node-master\starter-files\views\mixins\_storeForm.pug:1:1 > 1| mixin storeForm(store = {}) -------^ 2| form(action="/add" method="POST" enctype = "multipart/form-data" class="card") 3| label(for="name") name 4| input(type="text" name="name") Mixin storeForm declared without body at makeError

compiling pug templates to single client side js file

一曲冷凌霜 提交于 2021-01-28 05:54:40
问题 I just started working with pug and am using it for a small single page app. I'm using templates that are compiled to javascript functions that I will use in my SPA to render HTML. Using the pug-cli, I am able to generate multiple .js files that each contain the desired template function. However, instead of compiling multiple javascript files, I'd like to merge all the functions in a simple 'template.js' file that I can then call from my client app. Here's the command I'm currently using pug

Pug iteration: Cannot read property 'length' of undefined

假如想象 提交于 2021-01-27 12:15:17
问题 I am having the following data in js file: let data =[ {id:1,type:"action"}, {id:2,type:"comedy"} ]; and trying to print it using pug template doctype html html head title= title link(rel='stylesheet', href='stylesheets/style.css') body table tr th Id th Type each post in data tr td #{post.id} td #{post.type} block content I get the error as "Cannot read property 'length' of undefined" at the each post line app.js: var createError = require('http-errors'); var express = require('express');

Unable to include relative path file using Jade Template

橙三吉。 提交于 2021-01-27 04:11:52
问题 I'm receiving the following error when I'm attempting to include a file in the same folder: the "filename" option is required to use "include" with "relative" paths There are two files: index.jade list_of_items.jade .content-container .row .col-lg-10.col-lg-offset-1.col-xs-12 .row .col-xs-3 include list_of_items .col-xs-9 include content I tried to use base path, but then received the following error: the "basedir" option is required to use "include" with "absolute" paths The code for the

How to pass variables to Pug's `script.` block?

眉间皱痕 提交于 2021-01-03 03:14:13
问题 I have this code in my index.pug file doctype html html head title= title body script(src=`${source}`) script. for (var event of events){ VClient.Event.subscribe(event, createDiv); } And here is how I pass the variables from Express to pug. var express = require('express'); var app = express(); app.set('view engine', 'pug') app.get('/', function(req, res){ var id = req.query.id || 23717; var source = `https://some.source.url/${id}.js`; res.render('index', {title: 'Preview Embed', source:

How to pass variables to Pug's `script.` block?

亡梦爱人 提交于 2021-01-03 03:11:38
问题 I have this code in my index.pug file doctype html html head title= title body script(src=`${source}`) script. for (var event of events){ VClient.Event.subscribe(event, createDiv); } And here is how I pass the variables from Express to pug. var express = require('express'); var app = express(); app.set('view engine', 'pug') app.get('/', function(req, res){ var id = req.query.id || 23717; var source = `https://some.source.url/${id}.js`; res.render('index', {title: 'Preview Embed', source:

How to use vue.js in expressjs with pug

﹥>﹥吖頭↗ 提交于 2021-01-01 06:26:43
问题 Here is my code i tried In my .pug extends layout block content h1= title p Welcome to #{title} script(src='/javascripts/custom_vue.js') div(id="app") {{ message }} custom_vue.js new Vue({ el: '#app', data: { message: 'Hello Vue.js!' } }) error: D:\xampp\htdocs\test\express\report\views\vue.pug:8:9 6| script(src='/javascripts/custom_vue.js') 7| <div id="app"> > 8| {{ message }} ---------------^ 9| </div> unexpected text "{{ me" Error: D:\xampp\htdocs\test\express\report\views\vue.pug:8:9 6|

How to use vue.js in expressjs with pug

会有一股神秘感。 提交于 2021-01-01 06:25:34
问题 Here is my code i tried In my .pug extends layout block content h1= title p Welcome to #{title} script(src='/javascripts/custom_vue.js') div(id="app") {{ message }} custom_vue.js new Vue({ el: '#app', data: { message: 'Hello Vue.js!' } }) error: D:\xampp\htdocs\test\express\report\views\vue.pug:8:9 6| script(src='/javascripts/custom_vue.js') 7| <div id="app"> > 8| {{ message }} ---------------^ 9| </div> unexpected text "{{ me" Error: D:\xampp\htdocs\test\express\report\views\vue.pug:8:9 6|

pug variable not evaluated on a href tag

*爱你&永不变心* 提交于 2020-12-29 18:55:55
问题 In my Express JS web app, a login route renders some variables to the login pug view. In login.js router.get('/login', function(req, res, next) { var locations = ["Location 1", "Location 2"]; var count = 0; var title = 'Login'; console.log("req.originalUrl=" + req.originalUrl); res.render('login', { title: title, // Give a title to our page jsonData: locations, // Pass data to the View count: locations.length, originalUrl: req.originalUrl }); }); In login.pug extends layout block content div