Tag: 帕格

在Express中渲染玉石时包含其他文件的内容?

我有以下的layout.jade: !!! html head title= title link(rel='stylesheet', href='/stylesheets/style.css') body!= body 在正文中,我想包含另一个文件content.jade的内容。 我想在app.js中这样的事情: app.get('/test', function(req, res){ res.render('layout', { layout: false, body: include content.jade }); }); 但是它给了SyntaxError:'content'意外的标识符。 有没有办法做到这一点?

我如何提供index.jade?

我用快递,用玉来写我的看法。 其中之一就是一个index.jade文件,id就像你要的.html一样提供这个文件。 我将如何做到这一点? 我试过res.sendfile('views/index.jade')和res.sendfile('views/index.html') 谢谢!

Jade with Express – ReferenceError:窗口未定义

我是node.js的新手,我只是想学习如何使用Express和Jade。 jade.js中的这一行似乎正在引起一些问题: window.jade = require("jade"); 我可以启动我的服务器,但是当我在浏览器中访问它时,我得到这个错误: ReferenceError: window is not defined at C:\Users\User\Desktop\node-js-web\node_modules\jade\jade.js:3142:1 at Object.<anonymous> (C:\Users\User\Desktop\node-js-web\node_modules\jade\jade.js:3143:2) at Module._compile (module.js:441:26) at Object..js (module.js:459:10) at Module.load (module.js:348:31) at Function._load (module.js:308:12) at Module.require (module.js:354:17) at require (module.js:370:17) at Object.<anonymous> (C:\Users\User\Desktop\node-js-web\node_modules\jade\index.js:4:5) at Module._compile (module.js:441:26) 当我注释掉这一行时,我得到这个错误: TypeError: Object #<Object> has no method 'compile' at Function.compile (C:\Users\User\Desktop\node-js-web\node_modules\express\lib\view.js:68:33) at ServerResponse._render (C:\Users\User\Desktop\node-js-web\node_modules\express\lib\view.js:417:18) at […]

即使布局设置为True,快速Jade布局也不会呈现

我是Express for Node.js的新手,我刚刚按照Pedro Teixeira的Node Tuts Episode 9设置了一个简单的应用程序。 我想试验布局文件,所以我把布局设置为“真实”。 当我这样做的时候,它没有用我的布局渲染,只用我的身体渲染。 我应该怎样才能正确渲染? 下面是我的app.js文件,我的index.jade,我的layout.jade,和我的渲染页面的屏幕截图。 app.js var express = require('express'); var app = express.createServer(); app.configure(function () { app.use(express.logger(); }); app.set('views', __dirname + '/views'); app.set('view engine','jade'); app.set('view options', {layout: true}); app.get('/', function(request, response) { response.render('index'); }); app.listen(4000); index.jade h2 Hello p World! layout.jade !!! 5 html head title My template […]

Express 3中的Jade模板块传递variables

我使用Jade模板引擎运行Express 3.0。 我试图将一个模板页面的variables传递给主布局页面。 喜欢这个: layout.jade(snippet): !!! 5 html(lang='en') head meta(charset='utf-8') title= locals.title – if (typeof(stylesheets) !== 'undefined') each stylesheet in stylesheets link(rel='stylesheet', href='/stylesheet/#{stylesheet}.css') body block body landing.jade(snippet): stylesheets = ["landing"] extends layout block body h1 Test 1234 生成的代码不包含额外的样式表标签。 我试过- var stylehseets…和重命名“样式表”担心它可能是一个关键字。 有什么build议么?

如何在node.js中实现jade模板的inheritance

我在同一个文件夹中有两个玉模板,就像: |__layout.jade |__content.jade 而layout.jade是父模板,content.jade将inheritance它:所以在layout.jade : doctype 5 html(lang="en") head title= title body block content 在content.jade extends layout block content h1 this is frome nested template 但是,当我运行它时,inheritance不起作用,它只显示父模板的内容 所以我的代码有什么问题?

从Express / node.js Web应用程序预填充HTML / Jade

我有一个使用Express构buildnode.js的Web应用程序。 我正在使用Jade模板文件进行HTML显示。 在其中的一个显示中,我想要预先填充数据的各个字段。 数据存储在一个mongodb会话存储中,以及数据库中的一个单独的集合中。 我宁愿使用会话数据预先填充HTML / Jade显示中的这些字段。 我怎么能这样做(如果可能的话)?

不能传递一个嵌套的对象res.render()?

我想访问一个variables在客户端JavaScript, 通过玉 ,传递forms的服务器(节点) 。 所以我做了一个嵌套的对象: var clientData = {clientData:{ title: 'Title', body: "body", appadress: 'localhost' || req.host, socketport: socketport, } } 然后将这个对象传递给玉( 通过res.render ).. app.get('/', function(req, res){ clientData.clientData.appadress = req.host; res.render('index.jade', clientData)}); 这在玉是接收…(我相信) clientData:{ title: 'Title', body: "body", appadress: 'localhost' || req.host, socketport: socketport, } 然后我可以把它作为一个单独的对象传递给客户端的JavaScript。 script. var clientData = #{clientData} 但是这不起作用。 res.render()不是像这样或那样的其他东西的嵌套对象的问题?

错误:input是自我closures,不应该有内容

我试图拿起一些Jade来使用快递,我很难理解为什么我得到这个错误。 整个我的.jade文件是: .login #register div(style='float:right') p input.loginInput (type='text', name='user') p input.loginInput (type='password', name='pass') p input#button.loginInput (type='submit', value='Join') div(style='text-align:right;padding-right:110px;padding-top:3px;') p IGN: p Password: a(href='#' onclick='getProfileLogin()') < Back 我得到了上面的错误,以某种方式链接到input(它不会发生,当我删除它们)在line 13: a(href='#' onclick='getProfileLogin()') < Back

快速/节点问题与Jade模板中的静态文件的路由path

我有一个使用Jade模板的Node / Express应用程序,可导入一些静态文件。 我的玉模板的突出线条是这样的: layout.jade: head link(rel="stylesheet" href="/css/main.css) script(src="/vendor/jquery.js") block body h1 Hello world. mypage.jade: extend layout block body append p Here another line. 在expression,我正在路由我的意见是这样的: app.get('/', function(req,res) { res.render('index') } app.get('/mypage/', function(req,res) { res.render('mypage') } mypage.html的html现在有我的CSS和JavaScriptpath: /mypage/css/main.css /mypage/vendor/jquery.js 我怎样才能得到快速/翡翠正确地导入静态文件在我的头,即。 没有前缀的pathpath?