Tag: 帕格

在res.render()之后没有将手写笔应用于我的玉石文件

我似乎无法将我的项目中的手写笔文件编译为与玉文件结合使用的css文件。 翡翠文件的内容正在向浏览器显示,但没有像.styl文件中指定的格式化。 我认为这与我使用的path有关。 我对“/ public”感到困惑,应该是我在项目树中实际创build的目录,还是仅仅是当前位置的占位符或类似的东西? 以下是我需要的模块: var express = require('express'), connect = require('connect'), account = require('./account'), stylus = require('stylus'), nib = require('nib'), http = require('http'), path = require('path'); var app = express(); 以下是我的configuration代码: function compile(str, path) { return stylus(str) .set('filename', path) .use(nib()) } app.configure('development', function(){ app.set('port', process.env.PORT || 8888); app.set('views', __dirname + '/views'); app.set('view engine', […]

嵌套的玉模板黑色

在Jade中我正在努力嵌套inheritance。 可能有更好的方法来处理它比我目前正在尝试。 我有以下文件结构: views | |-index.jade |-layout.jade |-login.jade 我的layout.jade看起来像这样: html body block content 我的index.jade看起来像这样: extends layout block content .page-container .page-login block login .page-footer 我的login.jade看起来像这样: extends index block login welcome #{user} <do some logic here> 我使用像这样渲染它: res.render('index', { title: 'Welcome Home', user: 'Guest#342' }); 没有什么是在login块显示。 我一直在谷歌search一个小时,但无法find任何有关嵌套模板块的文档或示例。 更具体地说,将variables传递给子模板。 我猜这是不可能的。 我错过了什么或有没有更好的方法来做到这一点?

玉延伸布局,如果说

嗨,抱歉我的英语。 我有一个非常简单的“layout.jade” !!! 5 html head title= title link(rel='stylesheet', href='/stylesheets/style.css') body block content 和一个非常简单的“index.jade” extends layout block content – if (session) { p Welcome – } else { p Login -} 有了这个代码,我有一个空白页面。 现在,如果我从我的“index.jade”中删除extends layout ,我把代码直接放在“index.jade”,一切工作正常,也就是说我的条件声明给我<p>Welcome</p>或<p>Login</p>不再有空白页面。 我是nodejs的新手,我的问题对于你们许多人来说可能是明显的;) 谢谢!

使用node.js和Jade但是index.jade没有显示出来

我正在使用node.js和Jade,我在我的public / views文件夹中有index.jade,但是当我运行服务器并转到页面时,即使一切正常,没有错误,它应该呈现。 这是server.js中的代码: console.log("Hello, world!"); var express = require("express") , app = express() , http = require("http").createServer(app); app.set("ipaddr", "192.168.0.103"); app.set("port", 8080); app.set("views", __dirname + "/views"); app.set("view engine", "jade"); app.use(express.static("public", __dirname + "/public")); app.use(express.bodyParser()); app.get("/", function(request, response) { response.send("Server is up and running"); response.render("index"); }); http.listen(app.get("port"), app.get("ipaddr"), function() { console.log("Server up and running. Go to […]

Node.js Express应用程序中出现Jade(1.0+)模板错误:“不允许使用重复键”id“。

感谢您的任何build议: 在我的Express应用程序中 ,我将几个parameter passing给一个Jade模板,该模板现在会产生这个致命错误: Duplicate key "id" is not allowed. (从我可以收集,我没有传入任何参数与索引“id”到模板中) 该应用程序与翡翠0.32.0正常工作,但打破了任何版本1.0+。 这里是我构build参数数组(函数: setJadeVars ,第29行),然后将该数组传递到玉模板(第63行)的代码: https://github.com/rfcx/rfcx-api-express/blob/master/routes/index.js 这个错误似乎并没有把parameter passing给模板,因为错误只发生在我尝试使用这些参数的时候(例如,如果我传入参数,但是不会在任何地方调用它们,就会发生渲染正好)。 如果有帮助,这里是我传递给模板的对象的console.log转储: { current_page: [ 'about', 'About', '/about', 'Rainforest Connection | About', true, false ], app_version: '832292378e7a', node_env: 'development', title: 'Title (development)', segment_io_client_id: 'wimr8bjvcr', addthis_pubid: 'ra-xxx', bootstrap_cdn: '/vendor', googlelibs_cdn: '/vendor', videojs_cdn: '/vendor/video.js', cdnjs_cdn: '/vendor', rfcx_cdn: '/cdn', rfcx_vendor_cdn: '/vendor', […]

带有nodejs jade和ajax的静态导航栏和页脚

我试图通过点击我的导航栏中的链接来呈现静态导航栏和页脚之间的dynamic内容,但每次点击链接时都会复制包含导航栏和页脚的内容。 我使用快递和玉模板引擎节点。 这是我的(简体)最顶级的玉文件。 doctype html html head title= title // { links } body block navbar #navLinks.nav.navbar-nav a(href='/', id='home') Home a(href='/ourteam', id='team') Our Team a(href='/blog', id='blog') Blog #pageBody block content block footer // { footer content } // { scripts } 我的jQuery AJAX脚本: $('#navLinks').on('click', 'a', function(event) { event.preventDefault(); console.log("Hello world"); var url = $(this).attr('href'); updatePage(url); […]

如何在玉石中dynamic添加多个类名?

现在我只添加0位置的位置作为类名li.req.disabled(class =“#{artist.locations [0]}”) 即。 类=“德里” 但是我想在类名中添加artists.locations数组中的所有名字。 例如,如果我在artist.locations中有三个城市A,B,C,我想要class =“ABC” 谢谢,

是否有可能使用Jade将“variables”渲染为“variables”?

有没有可能使用Jade a variable渲染变成a-variable ? 用例如下: – pageTitle = 'Page Title'; body(class="#{pageTitle}") h1 #{pageTitle} 这将呈现为: <body class="page-title"> <h1>Page Title</h1>

Node JS + Express:在主视图中渲染子视图

我有一个“Google Card”devise的页面。 我想在这个主页的卡片上渲染一些视图。 卡界面如下所示: 因为可以有很多卡,我组织了我的项目模块。 (顺便说一下,如果你知道一个比Express更适合我的项目的框架,你可以告诉我吗?)) 我正在使用Express Framework的Node.js。 我的目录结构是这样的: |-app |–modules |—weather |—index.js |—-views |—–weather.jade |–views |–config.js |–server.js |-public |–assets |—img |—css |—… 这是我目前的一些代码: server.js: var express = require('express'); var app = express(); app.use("/public", express.static(__dirname + '/../public')); app.set('view engine', 'jade'); Board = {}; Board.modules = {}; Board.modules.weather = require('./modules/weather'); app.use(Board.modules.sticks); app.get('/', function(req,res){ tpl = {}; […]

Jade从路由器传递对象/数组时遇到错误

我正在探索Jade作为Node中的一个视图引擎,并花了3个小时不能将对象(来自数据库的响应)传递给Jade视图而不会出错。 从我的路由器all是一个数组与对象: var router = express.Router(); router.get('/all', function(req, res){ db.findAll().then(function(all){ res.render("index", { creators: all }); }); }); 玉观点: doctype html html head title my jade template body .comment_list each el in creators p= el.creator 如你所见,这很简单。 我已经看到了20多个使用Jade的例子,并且执行相同的操作,总是得到这个错误: > TypeError: index.jade:7 5| body 6| .comment_list > 7| each el in creators 8| p= el.creator Cannot read property […]