pug

Node, Express, Ajax, and Jade Example

空扰寡人 提交于 2019-12-04 04:31:56
I'm looking for a simple example of a Node/Express/Jade page being updated using an Ajax call with both the client and server side code. I'm having a bit of trouble putting it all together in my head. There are great many ways this could be done and it's not immediately apparent which approach you want to take. I suppose the simplest scenario would be to add some client-side logic to fetch pieces of html from the server and update the client. This is easily achieved using jQuery (put it inside a document ready block to wire up the event): $('#button').click(function() { $.get('/some/url', {foo

Heroku(Cedar) + Node + Express + Jade Client-side javascript files in subdirectory work locally with foreman+curl but not when pushed to Heroku

大兔子大兔子 提交于 2019-12-04 04:00:34
I am very new to node and heroku and I suspect this is some kind of simple permission issue etc, but I can't seem to track it down. I have several pure javascript files in a sub-directory one level beneath my root directory where my web.js file is sitting. I have a line in my web.js file to specify the directory app.use('/heatcanvas',express.static(__dirname+'/heatcanvas')); If I run my app locally with Heroku Foreman I get the expected js response when I run the following curl command curl localhost:5000/heatcanvas/heatcanvas.js However when I push to Heroku and hit the corresponsing live url

static javascript not rendering in jade (with express/node.js)

拥有回忆 提交于 2019-12-04 03:33:17
问题 I hope you are well. I'm suddenly unable to render any external javascript in jade templates! To get to the bottom of things, I stripped it down to the bare minimum : Node 0.6.11, Express 2.5.8, jade 0.20.3 app.js var express = require('express') , routes = require('./routes'); var app = module.exports = express.createServer(); app.configure(function(){ app.set('views', __dirname + '/views'); app.set('view engine', 'jade'); app.use(express.bodyParser()); app.use(express.methodOverride()); app

How do I render partials with jade without express.js?

 ̄綄美尐妖づ 提交于 2019-12-04 03:19:11
Only info I found was this: http://forrst.com/posts/Node_js_Jade_Import_Jade_File-CZW I replicated the suggested folder structure (views/partials) But it didn't work, as soon as I put !=partial('header', {}) !=partial('menu', {}) into index.jade, I get a blank screen, the error message I receive from jade is: ReferenceError: ./views/index.jade:3 1. 'p index' 2. '' 3. '!=partial(\'header', {})' partial is not defined I'd be very grateful for any help ! (I strongly prefer not to use express.js) I think partial rendering is done in express, so you will have to snag that code or write your own. I

Jade - Using Block inside script tag

会有一股神秘感。 提交于 2019-12-04 03:06:10
Hi there I'm trying using Jade's blocks and extends for a node.js project, and the ideia is to have something like this: layout.jade: head script $(document).ready(function() { block js_doc_ready //here goes the doc ready }); index.jade: block js_doc_ready alert('hello!'); alert('one more js line code'); alert('end my js doc ready for this view'); This would give me a index.html like this: ... <head> <script type="text/javascript"> $(document).ready(function() { alert('hello!'); alert('one more js line code'); alert('end my js doc ready for this view'); }); </script> </head> ... But when I see

Express+jade: local variable not available in view

北慕城南 提交于 2019-12-03 23:24:23
I ran into a very basic problem but I can't seem to find the answer to it. I am working with node.js , express and I am just trying to pass a local variable into the view like this: app.get('/', function(req, res){ res.render("index", {locals: { title: "Blog", } }); }); My index view is equally simple: h1= title But for some reason, I keep getting this error as if the local variable is never passed: 500 ReferenceError: /home/spartan/Node_Projects/test/views/index.jade:1 > 1| h1= title 2| title is not defined > 1| h1= title 2| title is not defined I don't know what I am doing wrong! Here are

Reload a page after res.redirect('back') in route

此生再无相见时 提交于 2019-12-03 23:17:48
问题 I'm working on an application which allows you to upload images, and create albums. Everything works fine accept that after an album is created the new album isn't shown in the client until the page is reloaded, and I can't figure out how to solve this. Below is the route for creating an album. Is it somehow possible to use something else than res.redirect('back') in this case so that the page is reloaded after the route has finished? Of course I could copy/paste the code from the route for

How to iterate and parse JSON data in Node/Jade/Express views?

六月ゝ 毕业季﹏ 提交于 2019-12-03 21:51:00
I am very new to Node and still in the beginning stages of understanding its use and power. I apologize if this question comes across as very simple or naive - I did due research before asking. In my express js application, I sent a GET request to a remote API and properly received the appropriate JSON data in return. I then passed it to my views (Jade) and currently have the ability the print the JSON in string form. That all works properly. The JSON data I have is a group of people/members of a club with associated fields. I want to "grab" all the people and display their names and related

Gulp using gulp-jade with gulp-data

落花浮王杯 提交于 2019-12-03 21:24:49
I'm trying to use gulp-data with gulp-jade in my workflow but I'm getting an error related to the gulp-data plugin. Here is my gulpfile.js var gulp = require('gulp'), plumber = require('gulp-plumber'), browserSync = require('browser-sync'), jade = require('gulp-jade'), data = require('gulp-data'), path = require('path'), sass = require('gulp-ruby-sass'), prefix = require('gulp-autoprefixer'), concat = require('gulp-concat'), uglify = require('gulp-uglify'), process = require('child_process'); gulp.task('default', ['browser-sync', 'watch']); // Watch task gulp.task('watch', function() { gulp

Toggle active link Bootstrap navbar

若如初见. 提交于 2019-12-03 20:11:42
I've read a lot of posts on the subject, found almost always the same solution but it does not work for me... My problem is as follows : I want to use Twitter Bootstrap 2.3.2 and its navbar, so I include the css and js files. Just before that, I also include jquery. I then take an example given on the bootstrap site which display very well. However, I now want to set the menu item clicked as active and remove the active class from all others. I saw in the bootstrap.js file that this function is built in, so no more script code to include. The problem is that the menu items do never toggle to