【问题标题】:Express JS create coffeescript scaffoldExpress JS 创建咖啡脚本脚手架
【发布时间】:2012-04-27 07:06:46
【问题描述】:

正在寻找一种直接在 coffeescript 中生成快速脚手架的方法。

目前$ express 'myapp'只是创建js文件。

任何指针将不胜感激。谢谢。

【问题讨论】:

    标签: javascript coffeescript express scaffolding


    【解决方案1】:

    您可以使用 js2coffee 将创建的 app.js 和 routes/index.js 文件转换为咖啡脚本(如 Slace 所述)
    有两种方法:
    1. 手动使用js2coffee.org converter
    2. 使用 js2coffee npm 包并将输出通过管道传输到新文件中

    $ cd my_new_express_app
    $ sudo npm install js2coffee -g
    Files can now be converted by running js2coffee input.js > output.coffee 
    $ js2coffee app.js > app.coffee
    $ js2coffee routes/index.js > routes/index.coffee
    

    这样您就可以在 coffeescript 中开始一个全新的 express 项目。请注意,转换会剥离 cmets。

    【讨论】:

      【解决方案2】:

      Express 仅从脚手架生成 JavaScript。您可以使用js2coffee 自己进行转换。

      【讨论】:

        【解决方案3】:

        如前所述,在生成您的 express 应用并安装 js2coffee 后,将目录更改为您的新应用并运行:

        for f in `find . -type f -path "*.js" ! -path "*node_modules*"`; js2coffee $f > "${f%.*}.coffee"
        

        【讨论】:

          猜你喜欢
          • 2014-06-29
          • 2013-01-09
          • 2012-07-10
          • 2011-09-03
          • 1970-01-01
          • 2011-11-08
          • 2011-06-30
          • 2013-06-10
          • 2012-08-26
          相关资源
          最近更新 更多