2
<b>ExpressJS Code

<code>
var express = require('express'),
    YUI = require('yui3').YUI,
    sys = require('sys'),
    util = require('util');

var app = module.exports = express.createServer();

app.get('/weather', function(req, res) {
    res.render('weather', {
      title: 'Weather',
      YUI: YUI
    });

</code>

At Jade Side

<code>
h1 test apge
   script(type="text/javascript")
      !=YUI  <<< this returns as text, but i want to access that object YUI
</code> 
How can I pass javascript objects from expressJS to Jade.
4

1 回答 1

0

您可以将 JSON 对象传递给翡翠模板,然后使用 JavaScript 解析 JSON。

例如

var JSON = {
 f : function(){alert("Hello")}
}

然后你可以调用 JSON.f

于 2011-09-13T13:42:09.287 回答