pug

How do I update A Jade Template form an ajax post?

心不动则不痛 提交于 2019-12-04 21:24:04
问题 I have set up a basic node.js web-app using express with the default view engine jade. When the User first loads the page the following occurs app.get('/', function(req, res){ res.render('index', { title: 'Test', mode: "user" }); }); What i cannot work out is how to then change the parameter I initially passed into the jade template from a ajax call. app.post('/', function(req, res){ console.log(req.body.list); res.redirect('back'); // I imagine the code needs to go here and look somewhat

Auto-Refresh Div in Jade Template (Node.js/Express)

佐手、 提交于 2019-12-04 20:45:05
I am using Node.js, Express, Jade, and Redis to develop an app that will display spots from a telnet stream provided by reversebeacon.net, which are cross-referenced against Redis databases of amateur radio club members and if they match are displayed on a table on my app. All this is working wonderfully so far. Unfortunately, I have to refresh the entire page to show new spots on the table. I would like to only refresh the div that contains the table (#activeDiv), instead of setting an interval that will refresh the entire page. Most examples I've encountered on the web have been geared

Include Angular into Hackathon-Starter

試著忘記壹切 提交于 2019-12-04 18:59:18
I'm quite a newbie. I try to include Angular into the https://github.com/sahat/hackathon-starter Boilerplate. I included //= require lib/ui-bootstrap-tpls-0.11.0 //= require lib/angular into the application.js and the two files into the lib folder. Still, the app does not seem to work on Angular yet. What do I do wrong? Where do I put my code for controllers/directives etc.? Using Hackathon-starter-angular (HSA) doesn't answer questions which were mentioned in the post. HSA includes AngularJS globally in the layout.jade file which might mean that all routes are served by AngularJS and those

Convert Jade to EJS

旧时模样 提交于 2019-12-04 17:21:12
Can anyone please help by convert this Jade to EJS? extends layout block content h1. User List ul each user, i in userlist li a(href="mailto:#{user.email}")= user.username There is no block but an include logic available in EJS. Split up the "main layout" that way that you can include a header and footer (or whatever suits your needs). The iteration is expressed in plain JavaScript escaped in sequences of <% ... %> . Using <%= ... %> directly outputs the referenced var. Your resulting EJS code might look as follows: <h1>User List</h1> <ul> <% for (var i = 0; i < user.length; i++) { %> <li><a

How to add pug to angular-cli?

北城以北 提交于 2019-12-04 17:15:11
问题 Anyone having luck adding .pug to angular-cli? I tried to do npm install pug --save, but I don't know where to change the .pug rendering instead of .html. Link for the angular-cli is here Please share a short tutorial, that would help a lof of people :) 回答1: For Angular 6+ you can simply run ng add ng-cli-pug-loader command in the root folder to turn on pug support in your angilar-cli project. 回答2: So after reading on angular-cli git, implementing pug is not in the near future. So here is my

What steps can be taken to improve jade template rendering performance in express using nodejs

我与影子孤独终老i 提交于 2019-12-04 16:45:11
问题 Background jade syntax is awesome but i wanted to see how it was affecting performance. So i created a single page app and used apache bench to compare its throughput using jade to render a page vs using an in memory string. There were no variables so this was a purely academic comparison. The in memory string made the entire app more than twice as fast locally, which seems a lot considering jade in production mode should be rendering from an in memory cache. I'm using node 0.8 and the

Passing variable from jade to ng-init not working

寵の児 提交于 2019-12-04 14:58:27
I'm trying to pass an object from jade to ng-init in angular This: doesn't work: ng-init='tables=!{JSON.stringify(tables)}' This: expands but, ng-init='tables=#{JSON.stringify(tables)}' the output is unescaped and filled with " s ng-init="tables={"12":{"id":.... and the view isn't updated in either of the cases. This article implies that first one should work, but like I said, it doesn't even expand, ng-init='tables=!{JSON.stringify(tables)}' in source code shows up exactly the same in the HTML source ng-init='tables=!{JSON.stringify(tables)}' Actually, the #{...} approach seems to work fine.

How to serve rendered Jade pages as if they were static HTML pages in Node Express?

血红的双手。 提交于 2019-12-04 14:07:19
Usually you render a Jade page in a route like this: app.get('/page', function(req, res, next){ res.render('page.jade'); }); But I want to serve all Jade pages (automatically rendered), just like how one would serve static HTML app.use(express.static('public')) Is there a way to do something similar for Jade? "static" means sending existing files unchanged directly from disk to the browser. Jade can be served this way but that is pretty unusual. Usually you want to render jade to HTML on the server which by definition is not "static", it's dynamic. You do it like this: app.get('/home',

sending mail with nodemailer - email from field incorrect

不羁的心 提交于 2019-12-04 12:50:05
Trying to set up a contact form with nodemailer. Here's what's in my app.js: // EMail configuration var smtpTransport = nodemailer.createTransport("SMTP",{ service: "Gmail", auth: { user: "myemailaddress", pass: "xxx" } }); // CONTACT FORM app.get('/contact', function (req, res) { res.render("contact"); }); app.post('/contact', function (req, res) { var mailOptions = { from: req.body.email, // sender address to: "myemailaddress", // list of receivers subject: req.body.subject, // Subject line text: req.body.message, // plaintext body } smtpTransport.sendMail(mailOptions, function(error,

How to configure express.js/jade to process html files?

前提是你 提交于 2019-12-04 12:32:09
I would like to configure jade engine to handle .html files in my views folder. Here is my currentserver configuration: app.configure(function(){ var pub_dir = __dirname + '/public'; app.set('port', process.env.PORT || 3000); app.set('views', __dirname + '/views'); app.set('view engine', 'jade'); app.use(express.bodyParser()); app.use(express.methodOverride()); app.use(express.cookieParser()); app.use(express.session({ secret: nconf.get("site:secret") })); app.use(everyauth.middleware()); app.use(require('less-middleware')({ src: pub_dir, force:true })); app.use(express.static(pub_dir)); app