pug

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

半城伤御伤魂 提交于 2019-12-06 15:13:42
问题 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

Update part of a page in jade?

*爱你&永不变心* 提交于 2019-12-06 15:02:40
问题 I'm trying to make a search and send back the result to the same site, I've got the search to work but I can't get the result to be sent back. I want the start site to render the information without page reload. How can I send the search result back to the index.jade page without having to update it? function pagelist(items, res) { var document=''; var db = db_login; if ( items != null){ items.forEach(function(item) { document += '<a href=share/'+item._id+' class="searchElement">' document +=

ClientJade - Trouble executing jade.render()

↘锁芯ラ 提交于 2019-12-06 14:41:38
I've run into a problem in the clientside code for a Node.js app I'm working on. The idea behind this is to update the browser immediately as the socket receives an event. This is the script block on the client side: script(src='/scripts/jadeTemplate.js') script(src='/socket.io/socket.io.js') script(type='text/javascript') var socket = io.connect(); socket.on('obj', function(obj) { var newsItem = document.createElement("item"); jade.render(newsItem, 'objTemplate', { object: obj }); $('#newsfeed').prepend(newsItem); alert(obj); }); When the alert() is placed before the jade.render() , it alerts

Include Angular into Hackathon-Starter

旧巷老猫 提交于 2019-12-06 14:05:35
问题 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.? 回答1: Using Hackathon-starter-angular (HSA) doesn't answer questions which were mentioned in the post. HSA includes

sails can't find layout.jade

北城以北 提交于 2019-12-06 13:42:28
I am starting to learn Sails (0.9.7, node 0.10.16) and running through the sailscasts episodes. I am also trying to use jade as I do so. Where I am stuck now is that sails is not finding views/layout.jade. I backed out all the jade stuff and redid with ejs and sails is not finding views/layout.ejs. As a last resort, I cloned activtyoverlord (the sailscasts app) and when I sails lift activityoverlord does not find its views/layout.ejs. Any suggests as to what I might be doing wrong? I'm not a jade user, however, I think you need to put extends ../layout at the top of your index.jade file to use

Grunt jade compiler filling out empty attributes

只谈情不闲聊 提交于 2019-12-06 13:40:28
I'm using the grunt-contrib-jade module to compile my Jade templates, if I leave my attribute blank like the following line: article(ui-view) It will compile to: <article ui-view="ui-view"></article> And that will break my AngularJS ui-router, as it will not handle the "ui-view" directive as if it is a named view (not what I want). Of course it's an option to write my jade file like this: article(ui-view='') But that's not what I want, is there some way to stop the jade compiler from filling out empty attributes? Gildor Everything seems good when there's doctype html at the beginning of the

How do I iterate over a JSON array using Jade and Node.js

时间秒杀一切 提交于 2019-12-06 12:54:11
So I have this JSON array apiData being passed on to the view as data . Backend router.get('/', function(req, res) { var data = JSON.stringify(apiData); res.render('gallery', { data: apiData }); }); Frontend extends layout block content h1 MyProject !{JSON.stringify(data)} I am trying to cache !{JSON.stringify(data)} in a variable and iterate through it in the jade file. I am completely new to jade. How could I go about doing this? You have a few problems in your code, like not using the stringification you do server side at all. But you don't even need JSON here. Simply pass the array and

How to prevent Jade Template parsing HTML attribute

烂漫一生 提交于 2019-12-06 11:06:16
问题 I am using Jade Template in conjunction with Angular JS and have such repeater processing simple array defined in angular's controller : $scope.ids = ['demo1', 'demo2'] .controls(ng-repeat="controlId in ids") <div id="{{$index}}">{{$index}}</div> Whatever i do Jade tries to parse everything passed to the SELECT tag and thus it always removes $index variable from tag's attribute. As result in HTML i always see the following: <div id="">0</div> // ID attribute is always empty because Jade

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

懵懂的女人 提交于 2019-12-06 08:17:10
问题 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? 回答1: "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

disable EJS caching in production

吃可爱长大的小学妹 提交于 2019-12-06 08:08:18
问题 It seems like whenever my process.NODE_ENV is set to production , EJS templating engine will cache all my .html files. So any modifications in those files will not be displayed, unless server restarts. app.engine('.html', require('ejs').__express); Is there a way to disable caching template on express? Thanks! 回答1: It seems like this is set explicitly as part of express's built-in code if (env === 'production') { this.enable('view cache'); } This gets called by app.init which is called by