使用Jade模板(jade-lang.com)客户端 [英] Using Jade Templates (jade-lang.com) client-side

查看:219
本文介绍了使用Jade模板(jade-lang.com)客户端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在客户端使用Jade模板。最好使用Rails 3.1资产管道生成。我无法弄清楚如何做到这一点。

I'd like to use Jade templates client-side. Preferably generated using the Rails 3.1 asset pipeline. I can't really figure out how to do this.

任何人偶然遇到同样的问题并找到了一个很好的解决方案?非常感谢任何想法。

Anyone who've stumbled upon the same problem and found a great solution? Any thoughts are much appreciated.

  • http://jade-lang.com/
  • http://ryanbigg.com/guides/asset_pipeline.html

推荐答案

PS:可能现在 Substack的回答更好。

P.S: Probably right now Substack's answer is better.

也许你可以使用 https://github.com/substack/node-browserify


浏览器端require()用于您的节点
模块和npm包

Browser-side require() for your node modules and npm packages

只需将一个或两个javascript文件指向
browserify即可将AST转到
递归读取所有require()s。
生成的捆绑包含你需要的所有
,包括使用npm拉入你可能已安装

库!

Just point a javascript file or two at browserify and it will walk the AST to read all your require()s recursively. The resulting bundle has everything you need, including pulling in libraries you might have installed using npm!



浏览器



http://jsperf.com/dom-vs-innerhtml-based-templating/53 =>根据此基准测试,性能不是很好=> http://gist.github.com/raw/550723/12d176698628e30a1df398c7ac7aea93924e1294/jade.js 。但根据TJ,它从来不应该在浏览器中使用,而是在node.js中使用。在那种情况下,它会非常快。您可以在浏览器中使用很多替代方案。

Browser

http://jsperf.com/dom-vs-innerhtml-based-templating/53 => The performance isn't that great according to this benchmark => http://gist.github.com/raw/550723/12d176698628e30a1df398c7ac7aea93924e1294/jade.js. But according to TJ it was never supposed to be used in the browser, but node.js instead. In that case it is going to be pretty fast. There are a lot of alternatives which you can use in the browser instead.

这篇关于使用Jade模板(jade-lang.com)客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆