pug

Can angular be used within a jade template?

≯℡__Kan透↙ 提交于 2019-11-28 08:35:13
问题 I am new to both angular and jade. I was wondering if angular can only be used with HTML, or if I could use the same angular call within a jade template? I have only seen angular templates being used with HTML, and have not found it used in any jade templates. is it possible to do such a thing? How would angular in a jade template look? 回答1: Yes you can. It would look something like: body(ng-app) button(ng-click="yourAngularFunc()") 回答2: You can download the angular-express-bootstrap-seed - A

javascript function execution inside jade template

感情迁移 提交于 2019-11-28 08:23:30
I am new to nodejs and trying to create a jade file for the html content myfile.jade : Here are the contents of the file: extends layout block content script function capitalize(s) { console.log("Testing js exec"); return s.charAt(0).toUpperCase() + s.slice(1); }; table - each item in list tr td a(href="/collection/#{item.name}") #{capitalize(itemName)} However, when running it throws the following error: Error: mweb/views/collections.jade:8 6| script 7| function capitalize(s) { > 8| console.log("Testing js exec"); 9| return s.charAt(0).toUpperCase() + s.slice(1); 10| }; unexpected text ; If I

socket.io - can't get it to work, having 404's on some kind of polling call

蓝咒 提交于 2019-11-28 06:46:25
I'm trying to get a server set up with socket.io, with bad results. I am mostly following this guide, although it's somewhat out of date: http://www.williammora.com/2013/03/nodejs-tutorial-building-chatroom-with.html The problem comes with socket.io, I'm not sure if it's client or server side. It appears to be trying to continuously poll the server, but is getting 404's back. That sounds like socket.io isn't running, but it all looks okay to me. It may also have something to do with paths and having a "public" directory, but I don't really know. 127.0.0.1 - - [Thu, 17 Jul 2014 00:51:36 GMT]

Error: Failed to lookup view in Express

╄→尐↘猪︶ㄣ 提交于 2019-11-28 05:38:58
Note : my auto answer at end of the post I'm trying to make a better experience of nodeJS and i don't really like to get all the script in one file. so, following a post here i use this structure ./ config/ enviroment.js routes.js public/ css/ styles.css images views index index.jade section index.jade layout.jade app.js My files are right now: app.js var express = require('express'); var app = module.exports = express.createServer(); require('./config/enviroment.js')(app, express); require('./config/routes.js')(app); app.listen(3000); enviroment.js module.exports = function(app, express) {

How to pass variable from jade-loader to a jade template file?

↘锁芯ラ 提交于 2019-11-28 05:23:48
问题 I want to pass my data-object to jade files, but but it is impossible My jade-loader : { test: /\.jade$/, loader: "jade", query: { pretty: true, locals: { name: "Georg" } } } plugins : plugins: [ new HtmlWebpackPlugin({ filename: "index.html", template: "./src/jade/index.jade" })] index.jade : span=locals.name I run webpack and I get this index.html : <span></span> My variable name don't pass. Why? How to fix it? 回答1: You can pass the custom properties to HtmlWebpackPlugin options and use

Node.js with Express: Importing client-side javascript using script tags in Jade views?

丶灬走出姿态 提交于 2019-11-28 04:11:25
I've got a node.js express server running with the Jade template engine. I've got a layout jade file which imports the body of individual views like so: !!! html head title= title || 'Title not set.' body #header h1 Header. #content!= body //- this renders the body of an individual view #footer p Footer. For example, the following index page: p Welcome to the front page. p This page serves as a now.js test. This works fine. However, I now want to include two client-side javascript libraries specifically for this index page (and thus not very every page, which is why I cannot put it in the head

Using HTML in Express instead of Jade

孤街浪徒 提交于 2019-11-28 02:54:40
How to I get rid of Jade while using Express with Node.JS? I want to just use plain html. In other articles I have seen that people recommended app.register() which is now deprecated in the latest version. Biwek You can do it this way: Install ejs: npm install ejs Set your template engine in app.js as ejs // app.js app.engine('html', require('ejs').renderFile); app.set('view engine', 'html'); Now in your route file you can assign template variables // ./routes/index.js exports.index = function(req, res){ res.render('index', { title: 'ejs' });}; Then you can create your html view in /views

What's the use of Jade or Handlebars when writing AngularJs apps

醉酒当歌 提交于 2019-11-28 02:47:23
I am new(ish) to the whole javascript full stack applications, and completely new to Angular, so I was hoping somebody can put the record straight for me here. Why would I need to use a templating framework like Jade or Handlebars when writing client side apps using AngularJS. I should say that I have never used any of these templating frameworks either. So I am not familiar with the advantages completely. But when I look at Handlebars for example, it does many of the same things as I would do in Angular, such as looping etc. As far as I can tell, it would make most sense to create the

AngularFire - Remove Single Item

China☆狼群 提交于 2019-11-28 01:18:27
Here is the relevant code in my view: p(ng-repeat="t in todos") input( type="checkbox", ng-model="t.done", ng-click="clearItem($event)" ) {{t.text}} done? {{t.done}} When the checkbox is clicked, I want the appropriate object in the todos array to be removed from the database. My clearItem function is as follows: $scope.clearItem = function(event) { todoRef.remove($scope.t); } However, this removes all the entries in my database. I want it to remove only the specific object in question. Is there anyway for me to do this? Ok, figured it out. When looping using ng-repeat , use (id, t) in todos .

Auto-compile Jade in Webstorm on Windows

懵懂的女人 提交于 2019-11-28 01:03:13
问题 I recently discovered Jade and want to give it a try for a new static website. I like the terse syntax and the templating capabilities, so much better than raw HTML. I'm editing in Webstorm 6, which has support for file watchers, and can run e.g. Sass out of the box. I've been able to run Jade via the command line to watch my Jade files: jade --watch --out public jade I'm now trying to configure my project in Webstorm to handle this automatically, and I'm running into problems. To keep the