pug

Node.js Express Firebase Can't set headers after they are sent

≡放荡痞女 提交于 2019-12-25 06:46:55
问题 I'm having problems saving data to Firebase and then redirecting to another page. I'm getting Error: Can't set headers after they are sent. I have read all the questions around this area on Stack but I can't get the following to work. app.route('/blog-add') .get(function(req, res){ var blogData = new Firebase(firebase_url+'blogs/'); var authData = blogData.getAuth(); var priority = 0 - Date.now(); if(authData == null) { res.redirect('/'); return; } else { var auth = authData.auth.uid; res

Asynchronous issue within nodejs/mongodb code

时间秒杀一切 提交于 2019-12-25 06:44:41
问题 I am new to nodejs/express/mongodb/jade and I have been trying for some time now to put together a simple site to help facilitate a more efficient way of reaching back to past data and being able to reuse it quickly. I determined the easiest way to us it would be do have a dynamic URL and had started to make good progress and then ran into a road block. End Goal: I am looking to use the URL params to determine which data is returned. Ran locally the syntax would look like localhost/

Bootstrap CSS overwriting my custom CSS

旧巷老猫 提交于 2019-12-25 05:15:18
问题 I am using Twitter Bootstrap's CSS and for some reasons it overwrites some of my classes. First I load it before my custom CSS (I am using jade and stylus template engines): HTML header: doctype html html head title= title link(rel='stylesheet', href='/css/vendor/bootstrap.min.css') link(rel='stylesheet', href='/css/style.css') in my HTML body: table.table.table-striped thead th some items th some items th some items tbody tr td.table__td a.table__link(href='/') some items tr td.table__td a

Jade Parser: “Anonymous blocks are not allowed unless they are part of a mixin” Error

混江龙づ霸主 提交于 2019-12-25 04:22:14
问题 I've got this error: "Anonymous blocks are not allowed unless they are part of a mixin" with this Jade file: html body style(type='text/css', media='screen') div#div_name display: block height: 300px obviously the problem is with display: block - any ideas \ solutions? 回答1: The following Jade style(type='text/css', media='screen') div#div_name display: block height: 300px will not compile. <style type="text/css" media="screen"></style> <div id="div_name"> <display><block></block></display>

gulp-browserify error during compilation of jade in html

血红的双手。 提交于 2019-12-25 03:45:11
问题 Sorry for possible mistakes in the writing - use the Google translator. I use the gulp-browserify gulpfile.js - gulp.task('jade', function(){ gulp.src('app/src/*.jade') .pipe(plumber(/*{ErrorHandler: notify.onError("<% error.massage %>")}*/)) .pipe(browserify({ transform: ['jadeify'], extension: ['.jade'] })) .pipe(rename('*.html')) .pipe(gulp.dest('app/dev')) }) error - [14:20:53] Plumber found unhandled error: SyntaxError in plugin 'gulp-browserify' /home/acopalipsis/proj/app/src/fake

Issue with Rendering templates with jade, express, and node.js

橙三吉。 提交于 2019-12-25 03:37:26
问题 I'm new to node.js, jade, & express, so please bear with me. I have the following files. layout.jade index.jade extends layout block content label initial layout form(action="/getReports", method="GET", enctype="multipart/form-data") input(type='submit', value='Generate Report') child.jade extends index block append content label added child server.js app.get('/getReports', function(res, req) { res.render("child.jade"); }); Process: User comes on and loads the site. They see the initial index

Syntax Error: /home/fzxa/work/blog2/views/articles/index.jade:7

只愿长相守 提交于 2019-12-25 02:22:00
问题 I am getting syntax error at line 7 of my Jade template: 5| div#articles 6| - if(articles.length) 7| !=partial('article_list', {collection : articles, as : 'article'}) 8| - else 9| #no-results No articles found. Create one 10| a(href="/articles/new") here Does anyone know why? 回答1: I found this possibly-similar issue on Github. https://github.com/visionmedia/jade/issues/81 You could try tossing in a line like cly does in that article to see if that fixes it: 5| div#articles 6| - if(articles

Include pug mixin from other view folder

牧云@^-^@ 提交于 2019-12-25 01:08:08
问题 I have set multiple view paths in my express application: express.set('views',['/path1', '/path2', '/path3']); When I am rendering my view, I want to include the pug file form path2 in path1 . # /path2/index.pug include path1/mixin.pug I can not find a solution for this problem. 回答1: I didn't use express.set views. Just do this in your pug file include ../path1/mixin.pug (or without .pug can also work) eg include ../path1/mixin Edit: For those that down voted this, you know nothing jon snow.

How to create a ajax POST with node JS?

大城市里の小女人 提交于 2019-12-24 21:30:07
问题 I am not sure how to use an ajax POST to POST from a Jade Page to Node JS. If someone can provide an example or tell me what I am missing from the script I have, please let me know. This is the script file: //Add friends $('.addContact').click(function() { $.post('/addContact', {friendRequest: $(this).data('user')}); if($(this).html!=='Contact Requested') { return $(this).html('Contact Requested'); } }); The url I have for a POST on my app.js file is: app.post('/addContact', user

Cannot read property 'length' of undefined pug

≡放荡痞女 提交于 2019-12-24 21:06:13
问题 I wrote this code and I get the error jade iteration: cannot read property 'length' of undefined trying to send data to pug view and i cannot read it because it's wrong app.get('/about', (req, res)=>{ var partners =[ { "name":"Name1", "image": "img1.jpg" }, { "name": "Name2", "image": "img2.jpg" }, {"name":"Name3", "image": "img3.jpg" } ]; let lang = getLang(req, res, ['about']); res.render('about', {partners , ...lang}); }); extends layout block content .subhead h2= about.title .content