pug

Expressjs not loading stylesheets on heroku, giving 500 error

℡╲_俬逩灬. 提交于 2019-11-30 10:16:45
I'm running an Expressjs installation on heroku, and it's not loading the stylesheets. I hit ctrl+u and then click on the stylesheet link, and get this error: TypeError: Object #<SendStream> has no method 'on' at Object.static [as handle] (/app/node_modules/express/node_modules/connect/lib/middleware/static.js:75:8) at next (/app/node_modules/express/node_modules/connect/lib/proto.js:190:15) When I go to the url '/stylesheets/style.css' I get this error: Express 500 TypeError: Object #<SendStream> has no method 'on' at Object.static [as handle] (/app/node_modules/express/node_modules/connect

How to insert raw HTML in Pug file (not include external HTML file)

本小妞迷上赌 提交于 2019-11-30 09:06:05
So what I want is to put some multiline HTML into a Pug file and can't find anywhere how to do this. Example: html head body <div><a href="lala"> blabla </a></div> p hihuhohoo Scimonster Pug text can include HTML. Just force it as text, and it should parse: html head body | <div><a href="lala"> blabla </a></div> p hihuhohoo Also, you were using backslashes, not forward slashes, to close elements. This is a tested example with passing variables with raw html to the pug file: yourSourceFile.js const p1 = 'This server uses a <a href="https://pugjs.org/api/getting-started.html" target="_blank">pug

Having problems with passing array to jade template in node.js

帅比萌擦擦* 提交于 2019-11-30 08:36:14
问题 I am trying to pass array of news to display on the screen but I somehow am getting empty array in the result in the browser routes/rss.js ... var news = []; ... var this_news = { 'title': item.title, 'description': item.description } news.push(this_news); ... res.render('rss', { title: 'Node.js based RSS reader', newsi: JSON.stringify(news) }); views/rss.jade extends layout block content h1= title p Welcome to #{title} p Sure why not script(type='text/javascript'). var inews = !{newsi}; EDIT

help with displaying a variable in jade express

折月煮酒 提交于 2019-11-30 07:56:09
问题 I'm trying to load some variables with res render like that: res.render('blog_edit', {title: 'edit your blog', posts: "something"}); though title loads fine post always appears as undefined... here are some of the ways I tried... =posts #{posts} and as a javascript variable script document.write(posts) none of them is working... can you please help? thanks in advance 回答1: try res.render('blog_edit', {locals:{title: 'edit your blog', posts: "something"}}); #{locals.foo} 回答2: I'm using the

Do I have to use   for space in Jade?

自作多情 提交于 2019-11-30 07:46:13
问题 I am using Jade and everything is cool except that Jade "eats" my spaces. For example, in HTML: <b>Hello</b> <b>World</b> or <b>Hello</b> <b>World</b> Will have a space between "Hello" and "World". But when converting to Jade it'd be b Hello b World When rendered as HTML, the space is gone. Like: <b>Hello</b><b>World</b> Do I have to add   in my Jade template or is there any way I can get a normal space in the generated HTML? 回答1: This should do it: b Hello | World Unfortunately it produces

nodejs, jade escape markup

久未见 提交于 2019-11-30 06:59:09
I have an Express app using the default Jade view engine. When I try to render HTML as-is in a <pre> element, it gets rendered as actual DOM elements instead of literal characters. h1 Code Sample pre code <div>some text</div> Output: <h1>Code Sample</h1> <pre> <code> <div>some text</div> </code> </pre> How do I escape the HTML so that it gets rendered as follows? <h1>Code Sample</h1> <pre> <code> <div>some text</div> </code> </pre> Jade uses the bang to force unescaped output. So you turn regular output to unescaped output with the following construct: != If your content is inside an div tag

Jade: How to include a javascript file

☆樱花仙子☆ 提交于 2019-11-30 06:02:37
I need to include a javascript file to webpage. I write the following: include /../scripts/jquery.timeago.js but I get <script>/* * timeago: a jQuery plugin, version: 0.8.2 (2010-02-16) * @requires jQuery v1.2.3 or later * * Timeago is a jQuery plugin that makes it easy to support automatically * updating fuzzy timestamps (e.g. "4 minutes ago" or "about 1 day ago"). * * For usage and examples, visit: * http://timeago.yarp.com/ * * Licensed under the MIT: * http://www.opensource.org/licenses/mit-license.php * * Copyright (c) 2008-2010, Ryan McGeary (ryanonjavascript -[at]- mcgeary [*dot*] org)

Jade to HTML converter [closed]

空扰寡人 提交于 2019-11-30 05:39:28
I have started writing an application using nodejs and jade, but after a while my team decided to switch to Django. I would still like to use the web pages written using jade, without having to re-write them by hand. Does anyone know of a tool that transforms jade code into html? As far as I've seen, most of the tools involving jade concentrate on the opposite transformation. Jade is supposed to come with a command line utility that does exactly that. See here https://github.com/visionmedia/jade#jade1 Or see just above it for a make file that runs it. - Edit - it seems Jade was renamed to Pug

how to protect a public dynamic folder in nodejs

邮差的信 提交于 2019-11-30 05:26:29
i show pictures with jade in public/images/picture.jpg but i want to protect some pictures or restrict the access to the public folder how do that?? project node_modules public images image.jpg javascripts stylesheets protected_folder* image_protected.jpg views Note: for all these examples, I'm using an application structured like the following: . ├── app.js └── public ├── protected │ └── file.txt <-- contains text "protected file" └── regular └── file.txt <-- contains text "regular file" You have a couple of options. The simplest one is to have Express route the request through your router

How does one add a conditional inside of a link in jade?

最后都变了- 提交于 2019-11-30 04:56:58
问题 How does one add a conditional inside of a tag (link/anchor in my case) in jade? Here's my pseudo code that of course won't work: a(href="/foo", class="if (current_route[1] == 'foo'){active}") Go to Foo 回答1: How about a(href="/foo", class=(current_route[1] === 'foo')? "active" : "") Go to Foo 来源: https://stackoverflow.com/questions/9488029/how-does-one-add-a-conditional-inside-of-a-link-in-jade