pug

Passing a variable from a jade file to a React Component

时光怂恿深爱的人放手 提交于 2019-12-12 12:26:55
问题 I am having trouble passing a variable from a .jade file to a react component. Here is a section of my jade file: block content #example var user = '#{user}'; span #{user.id} span #{user.displayName} And here is app.jsx, the react component that I would like to have access to the variable user. var React = require('react'); var HelloWorld = require('./HelloWorld.jsx'); var $ = jQuery = require('../../libraries/jquery/dist/jquery'); var bootstrap = require('../../libraries/bootstrap-sass

NodeJs website TTFB is very high and site is running very slow

只谈情不闲聊 提交于 2019-12-12 12:19:57
问题 I have created a website in nodejs with Express & Jade. When i load the simple login page with very less content, even then it taking is much time to load. It's TTFB is too high (ref to screenshot attached.) Below is my app.js code. Not sure what i'm doing wrong. app.js // Packages var express = require('express'); var path = require('path'); var favicon = require('serve-favicon'); var logger = require('morgan'); var cookieParser = require('cookie-parser'); var bodyParser = require('body

VueJS with HAML/Jade/Pug-like templating

孤者浪人 提交于 2019-12-12 12:13:50
问题 I'm using both Vue.js and HAML in my current project. The templates are parsed by HAML, converted into HTML, then parsed by Vue. For instance: #pagecontent.nonscrolling %h2 Demand forecasts %label{ for:"location-type" } Select location type %select.form-control#location-type{ v-model:"locationType" } %option{ v-bind:value:"'foo'" } Foo It works ok, but it's a bit disconcerting worrying whether all the Vue syntax will make it unscathed through the HAML parser. But I really like this type of

Arithmetic operators in JADE

陌路散爱 提交于 2019-12-12 11:24:54
问题 I'm using Jade template engine with NOde.js. I have two variables: a = 0.0378 b = 0.1545 in Jade I do: - var result = a + b*2 and I get a very strange number when I do #{result} 0.03780.309 It seems to concatenate the numbers as strings. Could someone tell me how can I use arithmetic operators in Jade? Thanks 回答1: Are you sure that a (and also b ) is a number and not a string? If it is a string you will need to to convert it to a number via parseFloat : - var result = parseFloat(a)+parseFloat

Jade template each loop to include jade file

北城余情 提交于 2019-12-12 11:23:45
问题 In the jade template engine: -can i do a each loop to include files? For e.g. each val in ['file1', 'file2', 'file3'] include val 回答1: "You are trying to include files dynamically through a loop. Dynamic inclusion is not supported." From the Jade issues section on Github: https://github.com/pugjs/jade/issues/1924 来源: https://stackoverflow.com/questions/23141365/jade-template-each-loop-to-include-jade-file

Express image upload and view in jade

旧城冷巷雨未停 提交于 2019-12-12 09:59:45
问题 I'm trying to upload an image and show it in express. I configured my app to upload in 'public/images' app.use(express.bodyParser({ keepExtensions: true, uploadDir: './public/images' })); The upload goes great but I can't find how to show uploaded images in my jade template. The image path I get from the req.files object is something like 'public/images/imagename.jpg' but the only way I can see images is in a url like this: http://localhost:3000/images/imagename.jpg Is there a way to maybe

Passing variable from jade to ng-init not working

亡梦爱人 提交于 2019-12-12 08:56:32
问题 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

how to use both ejs and jade in one nodejs & express project?

女生的网名这么多〃 提交于 2019-12-12 08:09:05
问题 I want to use ejs for partials and use jade for individual pages, how to use both in one nodejs & express project? 回答1: It 's easy to find the way in expressjs api docs and consolidate.js at github Reference the express.js doc fragment below, please app.engine(ext, callback) Register the given template engine callback as ext By default will require() the engine based on the file extension. For example if you try to render a "foo.jade" file Express will invoke the following internally, and

Nodejs + ExpressJS + Jade + Post no render

佐手、 提交于 2019-12-12 06:49:38
问题 1˚ - Client: $.ajax({ type: 'POST', data: data, url: '/someposturl', success: function (data) { console.log('success'); // $('body').html(data); // i don't want it, but if not so, nothing happens (render) } }); 2˚ - Server: app.get('/criptografar', function (req, res) { console.log(req.something); res.render('somepage', { somevar: withsomevalue }); //-I want this to work like a normal post }); 3˚ - Client -> 'somepage' - not rendered without this in the client: $('body').html(data); // i don

Use Jade as angular2 template engine

自古美人都是妖i 提交于 2019-12-12 05:59:56
问题 I'm currently trying to migrate to developing MEAN apps with Angular2 in place of Angular1.x but i'm currently having an issue based on using jade/pug as my template engine in angular2. I saw a post on how to implement this with webpack, but that tutorial is meant for another project structure and not the official angular/cli. So i'm asking if there's a way jade/pug can be used as template engine with the angular/cli project structure? 回答1: Integrating Pug with angular/cli is pretty easy. All