pug

how to using jade Mixin in Javascript?

删除回忆录丶 提交于 2019-12-10 21:04:58
问题 In jade, i'm make test mixins mixin test(testName) #test span Test String But i want using this in javascript (this is declare in jade file) script(type='text/javascript'). $( document ).on( "click", "#addBtn", function() { $("#list").append( I WANT USE MIXIN THIS PLACE ); }); How to use mixin in javascript? 回答1: You can't use a Jade mixin in a JavaScript file because Jade templates are rendered on server side. 来源: https://stackoverflow.com/questions/24068728/how-to-using-jade-mixin-in

Interploating values in HTML attributes - Pug(Jade)

自作多情 提交于 2019-12-10 20:23:43
问题 I am trying to construct an anchor tag with href attribute interploated in Jade. I did go through http://jade-lang.com/reference/interpolation/ and some SO questions but didn't help me. This is what I tried. a(href= "http://www.imdb.com/title/#{movie.imdb_id}") Know more But it renders http://www.imdb.com/title/#{movie.imdb_id} rather than http://www.imdb.com/title/tt1234567 However this works a(href= "http://www.imdb.com/title/" + movie.imdb_id) Know more and this too. - var url = "http:/

Pass a param from pug to JSX

China☆狼群 提交于 2019-12-10 18:28:13
问题 I'm building a game using Express and React. I need to access the userId in my index.jsx file to perform actions on my controllers, like increment the user score. My route renders an index.pug file while passing a user_id param: //server.js app.get('/', function (req, res) { const userId = req.query.userId res.render('index', {userId: userId}) }) Then I can access the userId in my pug file, like this: // index.pug body div#errors #root p #{userId} // prints the User Id Now I need to access

Read checkbox value Node JS + Express + Jade

眉间皱痕 提交于 2019-12-10 18:09:46
问题 I'm inserting web page values into a Mongo DB, Im using Node JS + Express + Jade. and I need to insert True or False, depending if checkbox is enabled or not. In my router.js I have the following: app.get('/notification', function(req, res) { res.render('notification', { title: 'Nueva notificacion', notifications : NT }); }); app.post('/notification', function(req, res){ console.log('Adding new notification'); AM.addNewNotification({ name : req.param('name'), notification : req.param(

Zurb Foundation Sticky Nav Bar

假如想象 提交于 2019-12-10 17:18:33
问题 So I'm using the default .top-bar class from the zurb foundation framework, but I'm failing a find a simple way to make the nav bar 'sticky' (follows the user as he scrolls), such as you can do with Twitter bootstrap. Here's my code, I'm using jade: nav.top-bar ul li.name h1 a(href='#') Site Title li.toggle-topbar a(href='#') section ul.left li.divider li a.active(href='#') Link li.divider li a.active(href='#') Link li.divider li a.active(href='#') Link li.divider li a.active(href='#') Link

Executing Express res.render in a async manner

╄→гoц情女王★ 提交于 2019-12-10 16:57:15
问题 I have a nodejs application where res.render method of express is taking about 400 ms in a blocking way. How do I handle this to execute in a non blocking way? My apache benchmark takes 12 seconds for executing around 30 concurrent requests. How do I implement this in a better manner? var start = +new Date; //fetch data from redis console.log('time taken to fetch data from redis ' + (+new Date - start)); //30 ms res.render('some_jade_view', params); console.log('time taken to render data ' +

Jade — nested html tag in one line

守給你的承諾、 提交于 2019-12-10 16:36:51
问题 According to Jade documentation, I can write: div ul li.active one li two li three I am considering something like this: div - ul li.active one li two li three How can I put multiple html tags in one line? I did not find a way in the documentation. Thanks in advance. :) 回答1: div: ul li.active one li two li three https://pugjs.org/language/tags.html 来源: https://stackoverflow.com/questions/29232733/jade-nested-html-tag-in-one-line

Jade/Pug JSON interpolation with objects

随声附和 提交于 2019-12-10 15:18:11
问题 I can't seem to find any sufficient documentation on the behavior of Pug with JSON interpolation. It seems that you can , but the methods I've found differ wildly and none do quite what I want. I'm using gulp-pug, by the way. Is it possible, given a JSON object like so: { 0: {name: "zero", desc: "the additive identity"}, 1: {name: "one", desc: "the multiplicative identity"}, 2: {name: "two", desc: "the first prime number"} } to interpolate a template something like this ul li(interpolated=0)

Express redirecting doesn't change req.url

本小妞迷上赌 提交于 2019-12-10 14:32:41
问题 I have a route that redirects upon successful login app.post('/login', function(req, res){ if(req.body.password === Server.cfg.auth.userPass) { req.session.user = {nick: req.body.username, pass: req.body.password} res.redirect('/chat') } else { res.render('user/login', { locals: { error: 'Invalid password' } }) } }) The redirect seems to work as the page is refreshed with the correctly rendered jade file. However, the url still says /login and my pageTitle variable (being set through template

Multilingual Jade templates?

穿精又带淫゛_ 提交于 2019-12-10 13:46:26
问题 I'm using the Jade template engine with gulp, gulp-jade and gulp-data to build a very basic one-page website in two languages. The result should be static HTML documents with no further server-side or client-side processing. Is it possible to load website content from a JSON file depending on a language I define in my index.jade , and what would be the best way to go about doing this? My current attempt causes an error: gulpfile.js: gulp.task('views', function () { return gulp.src('app/**/*