pug

Express.js how to make html render on client side with response.render?

大城市里の小女人 提交于 2019-12-01 12:19:01
I have basic express js application with following route: router.get('/', function(req, res){ res.render('login'); }); It works fine - after logging into main page on my localhost, html from login.pug is nicely rendered on client side. However when my app runs, sometimes I want to render another pug file, when there already is html rendered on client side: app.get('/dashboard', function(req, res){ res.render('dashboard', {user: req.query.login}); }); But when get request is send on 'dashboard' path, nothing happens. As I understand, this happens because res.render just parses pug file into

Express.js how to make html render on client side with response.render?

痞子三分冷 提交于 2019-12-01 12:02:59
问题 I have basic express js application with following route: router.get('/', function(req, res){ res.render('login'); }); It works fine - after logging into main page on my localhost, html from login.pug is nicely rendered on client side. However when my app runs, sometimes I want to render another pug file, when there already is html rendered on client side: app.get('/dashboard', function(req, res){ res.render('dashboard', {user: req.query.login}); }); But when get request is send on 'dashboard

How do I pass variable from a Jade template file to a Javascript file?

穿精又带淫゛_ 提交于 2019-12-01 11:50:11
Im very new to Node.js and trying to get my head round few things.How do I pass variable from a Jade template file to a JS file? I have got this line of code in my server.js file res.render("aws.jade", {data : JSON.stringify({'val' : 'This is a Test'})}); Basically Im just trying to get values in data to aws.jade template file And this is aws.jade html head script(type='text/javascript') var data = !{data} link(rel='stylesheet', href='/stylesheets/style.css') body title Title h1 Heading #div.test I keep getting this error in the Firebug console: <var>data = {"val":"This is a Test"}</var> Could

How do I pass variable from a Jade template file to a Javascript file?

柔情痞子 提交于 2019-12-01 10:30:05
问题 Im very new to Node.js and trying to get my head round few things.How do I pass variable from a Jade template file to a JS file? I have got this line of code in my server.js file res.render("aws.jade", {data : JSON.stringify({'val' : 'This is a Test'})}); Basically Im just trying to get values in data to aws.jade template file And this is aws.jade html head script(type='text/javascript') var data = !{data} link(rel='stylesheet', href='/stylesheets/style.css') body title Title h1 Heading #div

Pug support for Angular 2 / Angular 4 / Angular 6 / Angular cli / Angular cli 6 (without custom WebPack config)

感情迁移 提交于 2019-12-01 09:55:49
问题 How to install correctly PUG / JADE to Angular 2 or above So that while working and AOT and JiT Worked Unit and Integration Tests and do not suffer much when creating each new component 回答1: I saw many solutions, some of them: in each component was added something like "require!pug-loader()some.component.pug" Get away from using angular-cli and create magic around webpack Use other servers (who know how to work with the Pug / Jade) Before running the build, convert all the pug files to html I

html special characters in css content, using attr()

我们两清 提交于 2019-12-01 09:17:38
Relevant codepen: http://codepen.io/anon/pen/ocptF/ EDIT: The codepen uses Jade, and thus messes a few things up. I was not aware of this when starting this question. Essentially, I thought CSS attr() would copy over an HTML attribute literally, but that is not the case. I'd like to use the CSS attr function to fill in the content for some pseudoelements. However, it prints out 004 when the HTML attribute is set to \f004 , and 08fa when \f08fa . Relevant lines: HTML: <div class="zoomfade" data-fill='\f004' data-unfill='\f08a'></div> CSS: .zoomfade:before { content: attr(data-unfill); position:

How can I extend jade layout from a view/parent/child structure?

拈花ヽ惹草 提交于 2019-12-01 07:14:09
问题 I have my Views structured like this I wanted to extend the layout.jade to all jades under my user folder. Doing extends ../layout in the files under user folder doesn't work. There are no much writing about extending layouts that discuss about this. Does Express allows this kind of extends? 回答1: extends ../layout should work fine. Here is how I structure my views. What happens when you try to render the child template? Are you using blocks like I am, or includes? // ls +views +children

Render table with Jade/Express.js having multiple elements per row

女生的网名这么多〃 提交于 2019-12-01 07:08:48
问题 I'm trying to render a table using jade from a simple array of objects. But instead of simply rendering one row per object, I want to render three objects on each row. <table> <thead>...</thead> <tbody> <tr> <td>obj0</td> <td>obj1</td> <td>obj2</td> </tr> <tr> <td>obj3</td> <td>obj4</td> <td>obj5</td> </tr> ... </tbody> </table 回答1: objects = [[obj0, obj1, obj2], [obj3, obj4, obj5]] table thead tbody for object in objects tr for subobject in object td= subobject 回答2: Accepted answer

html special characters in css content, using attr()

梦想与她 提交于 2019-12-01 06:03:51
问题 Relevant codepen: http://codepen.io/anon/pen/ocptF/ EDIT: The codepen uses Jade, and thus messes a few things up. I was not aware of this when starting this question. Essentially, I thought CSS attr() would copy over an HTML attribute literally, but that is not the case. I'd like to use the CSS attr function to fill in the content for some pseudoelements. However, it prints out 004 when the HTML attribute is set to \f004 , and 08fa when \f08fa . Relevant lines: HTML: <div class="zoomfade"

How can a Jade template use client-side global variables?

最后都变了- 提交于 2019-12-01 05:22:18
Lets say I have a browser open, and in JavaScript I declare a global variable. window.myGlobalVar = 'Hello!'; I then compile a jade template for client side rendering that uses that variable. .foo= myGobalVar Which I compile like so: jade.compile('.foo= myGobalVar', { client: true, compileDebug: false }).toString() Which yields this template function: function anonymous(locals) { var buf = []; var locals_ = (locals || {}), myGobalVar = locals_.myGobalVar; jade.indent = []; buf.push("\n<div class=\"foo\">" + (jade.escape(null == (jade.interp = myGobalVar) ? "" : jade.interp)) + "</div>");;