7
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Rendr入門(3): CoffeeScriptでRendrアプリを書く

Posted at

Rendrは最初CoffeeScriptで書かれていたのですが、より多くのエンジニアに開発に参加してもらいたいという理由でピュアJavaScriptになりました。しかし、アプリ・コードはCoffeeScriptで記述することができます。

下記の3ステップが必要です。

package.jsonに'coffee-script'を追加


"dependencies": {
    "express": "~>3",
    "underscore": "~1.4.4",
    "async": "~0.1.22",
    "request": "~2.16",
    "rendr-handlebars": "0.0.5",
    "rendr": "0.5.0-alpha04",
    "debug": "*",
    "coffee-script": "*"  これを追加

$ npm install
も忘れずに。

index.jsでrequire('coffee-script')する

そのままですね。index.jsの先頭にrequire('coffee-script');と書きます。

index.jsでserverの'view engine'の設定を上書きする

app.use(server);

server.configure(function(rendrExpressApp) {
  rendrExpressApp.set('view engine', 'coffee');
});

これをしないと、CoffeeScriptで書かれたView(app/views/の下)が認識されません。

以上です!

7
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?