LoginSignup
11

More than 5 years have passed since last update.

jadeはpugにリネームされたのでexpressでpugを使う

Last updated at Posted at 2016-05-29

概要

jadeはpugにリネームされました。商標問題か何かだと思いますが詳しくは追ってません。各自お調べ頂くとして...。

Express Generator

2016年5月30日現在、ジェネレータが吐き出すコードはいまだにjadeなので、pugを利用するようにします。

いったんジェネレータでひな形を吐き出させます。

$ mkdir myapp
$ cd myapp
$ express ./

吐き出されたapp.jsを書き換えてテンプレートエンジンを変更します。

app.js
app.set('view engine', 'pug');

./views/の中のjadeファイルの拡張子を変更します。

ワンライナー
$ for f in ./views/*.jade; do mv $f ${f%.jade}.pug; done

package.json から jade を消します。

package.json
--- package.json.old    2016-05-30 00:54:35.000000000 +0900
+++ package.json    2016-05-30 00:55:00.000000000 +0900
@@ -10,8 +10,7 @@
     "cookie-parser": "~1.3.5",
     "debug": "~2.2.0",
     "express": "~4.13.1",
-    "jade": "~1.11.0",
     "morgan": "~1.6.1",
     "serve-favicon": "~2.3.0"
   }
-}
\ No newline at end of file
+}

pugをインストールします。

$ npm install -S pug

その他のパッケージもインストールします。

$ npm install

以上!

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
11