English 中文(简体)
node.js + Express.js + dust.js 问题
原标题:node.js + express.js + dust.js issues

The quick question: why won t express.js run with dust.js?
I know it s not officially supported, but dust.js even has issues with my node.js version.
Node won t even start due to require.path issues.

server:testapp treejanitor$ node --version
v0.6.12

当将应用程序引擎设置为灰尘时, 我就会遇到问题 。 (app.js in Express)

var dust = require( dust );
...
app.set( view engine ,  dust );

I m showing the console here to give you my simple list of modules.
Also someone searching for the same problem might cut/paste the error.

server:hummr treejanitor$ npm list
[email protected] /Users/treejanitor/git/testapp/testapp
├── [email protected]  extraneous
├── [email protected] 
├─┬ [email protected] 
│ ├─┬ [email protected] 
│ │ └── [email protected] 
│ ├── [email protected] 
│ ├── [email protected] 
│ └── [email protected] 
└─┬ [email protected] 
  ├── [email protected] 
  └── [email protected]

server:testapp treejanitor$ supervisor app.js

DEBUG: Error: require.paths is removed. Use node_modules folders, or the NODE_PATH environment variable instead.
    at Function.<anonymous> (module.js:378:11)
    at Object.<anonymous> (/Users/treejanitor/git/testapp/testapp/node_modules/dust/lib/server.js:6:8)

I tried the following attempt with no luck:
Dust.js load template from filesystem in Node.js

NOTE: I tried the alpha version of express (3.0) which didn t help.
Same goes for consolidate.js and all the modules in that example.


Some reasons why I am interested in node + express + dust:
LinkedIn picks dustjs
Twitter s Bootstrap framework

问题回答

我曾经讨论过在Node.js 0.6.x上用concommunate.js melf="/cdn-cgi/l/email-protection"类"="__cf_email_"数据 -cfemail="286d50585a4d5b5b5b681b0618" <[email protect] /code>在Node.js 0.6.x上设置Dust.js.js 模块。您可以 在这里阅读

然而,您可能想要使用 < a href="https://github.com/linkin/dustjs" rel="noreferrer" >LinkedIn sfork of Dust.js , 支持将Node.js 0.6.x从盒子里拿出, 并加上其他改进。

Concommunate.js 已经支持该叉子,但您仍然需要

So here s the trick - I thought I d share what I found.
It required finding this nugget - search for dust-x in the page if you re interested. http://nodejs.debuggable.com/2012-03-23.txt

解决事情,在您的快件应用程序中

cd node_modules
git clone git://github.com/laurie71/dust-x.git
git clone https://github.com/caolan/dustjs.git

The fork of dust.js resolving the require.paths issue with node.js
https://github.com/caolan/dustjs

The wrapper of dust making it available as a template engine
(You ll still need dust.js installed as a module)
https://github.com/laurie71/dust-x

The example usage
https://gist.github.com/2174537

最重要的一点 :

var dustx = require( dust-x );

...

// Configuration

app.configure(function(){
    app.set( views , __dirname +  /views );
    app.register( .dust , dustx/*({})*/);
    app.set( view engine ,  dust );
    // app.set( view engine ,  jade );
    app.use(express.bodyParser());
    app.use(express.methodOverride());
    app.use(app.router);
    app.use(express[ static ](__dirname +  /public ));
});

Btw, 我想我可以手动修好服务器中的灰尘。 Js 问题,


PS:我还是比较新到在堆积流上张贴信息,所以如果我违反了一些礼仪,请告诉我。我在常识中读到,回答你自己的问题是受到鼓励的,所以我想我试试看。

特别是,我知道我的格式可能很弱。 在答案中, 我实际上更喜欢显示完整链接, 而不是显示向导建议嵌入的 URL, 因为它揭示了包含网站的结构。 随着网站的 URL 渗入你的大脑, 它使您有更多机会访问该网站作为参考。 URL 也相当短 。 < {} () < strong> suggests are 非常感谢 . .

控制台通常格式化的方式是什么? 作为代码吗?

It could be an issue with node.js and express.js versions..I am using node v0.10.9 and express v3.0.x and they work well for me. For integrating dust.js with express.js and node.js, I found this github repo to be a useful resource to help you get started with: https://github.com/chovy/express-template-demo (It uses the linkedin fork of dust.js)





相关问题
Check session from a view in CodeIgniter

What is the best way to check session from a view in CodeIgniter, it shows no way in their user guide, otherwise I will have to make two views on everything, which is kinda weird...still a newbie to ...

How to create a submit button template in Oracle APEX?

I m trying to create a template for a button in Oracle APEX but I don t seem to have access to the appropriate substitution strings to make it work. For non-templated buttons APEX seems to insert a ...

list of controls with templates in silverlight

Does anyone know where to find a list of controls that you can set the template on in Silverlight? I ve wasted several hours now trying to create control templates only to find that the control doesn ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Load ruby on rails template from database

I wonder if there is a way for me to store ruby on rails view files into database store and have that fetched directly from there. The reason is I want to create a CMS with all the user data stored in ...

Templated HTML Editor

I m looking for a HTML editor that kinda supports templated editing or live snippets or something like that. Background: I m working on a website for a friend. As there are no specifications what the ...

Dreamweaver changing path to site s reference instead of local

I have noticed recently, when I apply a template to a new HTML website, all the relative paths are pointed to my local files, example: file:///C|/webstuff/files but I cannot set them to relative paths ...

WPF ListView : Header styling

I want to have a ListView with columns and a particular style: The background for ALL column headers should be transparent except when the mouse is over in one of them. When this happends, the ...