{"id":5173,"date":"2014-03-16T18:27:25","date_gmt":"2014-03-16T09:27:25","guid":{"rendered":"http:\/\/www.webcyou.com\/?p=5173"},"modified":"2014-03-16T20:02:16","modified_gmt":"2014-03-16T11:02:16","slug":"node-js-%e3%83%86%e3%83%b3%e3%83%97%e3%83%ac%e3%83%bc%e3%83%88%e3%82%a8%e3%83%b3%e3%82%b8%e3%83%b3-ect%e3%81%8c%e7%88%86%e9%80%9f-%e3%82%89%e3%81%97%e3%81%84%e4%bb%b6%ef%bc%88ect%e3%81%ae%e4%bd%bf","status":"publish","type":"post","link":"https:\/\/www.webcyou.com\/?p=5173","title":{"rendered":"node.js \u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30a8\u30f3\u30b8\u30f3 ECT\u304c\u7206\u901f!! \u3089\u3057\u3044\u4ef6\uff08ect\u306e\u4f7f\u3044\u65b9\uff09"},"content":{"rendered":"<p>node.js\u3067webApp\u3092\u4f5c\u6210\u3059\u308b\u969b\u3001Express\u3092\u7528\u3044\u305f\u69d8\u3005\u306a\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30a8\u30f3\u30b8\u30f3\u304c\u5b58\u5728\u3057\u307e\u3059\u3002<\/p>\n<p>\u6709\u540d\u3068\u3053\u308d\u3067\u3001\u300cEJS\u300d\u3084\u300cjade\u300d\u7b49\u3005\u3068\u3042\u308b\u306e\u3067\u3059\u304c\u3001\u305d\u306e\u4e2d\u3067\u3082\u7fa4\u3092\u629c\u3044\u3066\u7206\u901f\u3068\u3044\u308f\u308c\u3066\u3044\u308b\uff08\u3046\u305f\u3063\u3066\u3044\u308b\uff09\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30a8\u30f3\u30b8\u30f3\u304c\u300cECT\u300d\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<h5><strong>ECT<\/strong><\/h5>\n<p><a href=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/747bd66fdf238bb842c11ed27eb71773.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/747bd66fdf238bb842c11ed27eb71773.png\" alt=\"\" title=\"\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2014-03-16 6.51.24\" width=\"477\" height=\"72\" class=\"alignnone size-full wp-image-5174\" srcset=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/747bd66fdf238bb842c11ed27eb71773.png 477w, https:\/\/www.webcyou.com\/wp-content\/uploads\/747bd66fdf238bb842c11ed27eb71773-300x45.png 300w\" sizes=\"auto, (max-width: 477px) 100vw, 477px\" \/><\/a><\/p>\n<p><strong>\u516c\u5f0f\u30da\u30fc\u30b8<\/strong><\/p>\n<p><a href=\"http:\/\/ectjs.com\/\">http:\/\/ectjs.com\/<\/a><\/p>\n<p>\u78ba\u304b\u306b\u3001Jade\u3092\u4f7f\u3063\u3066\u3044\u305f\u6642\u30da\u30fc\u30b8\u8868\u793a\u306e\u300c\u9045\u3055\u300d\u3092\u611f\u3058\u3066\u3044\u307e\u3057\u305f\u3002<\/p>\n<p>\u304b\u3068\u3044\u3063\u3066\u300cEJS\u300d\u3092\u4f7f\u304a\u3046\u3068\u601d\u3063\u3066\u3082\u3001Express2 \u307e\u3067\u4f7f\u3048\u3066\u3044\u305flayout\u3001partial\u3001block\u7b49\u304c\u3001<\/p>\n<p>Express3\u304b\u3089\u306f\u3001\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u90e8\u5206\u3068\u5206\u96e2\u3057\u30b7\u30f3\u30d7\u30eb\u306aAPI\u306b\u3059\u308b\u305f\u3081\u3001ejs-locals\u306b\u79fb\u3063\u305f\u3088\u3046\u3067<\/p>\n<h5>ejs-locals github<\/h5>\n<p><strong><a href=\"https:\/\/github.com\/RandomEtc\/ejs-locals\" target=\"_blank\">ejs-locals<\/a><\/strong><\/p>\n<p><a href=\"https:\/\/github.com\/RandomEtc\/ejs-locals\" target=\"_blank\">https:\/\/github.com\/RandomEtc\/ejs-locals<\/a><\/p>\n<h5>ejs-locals\u00a0\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h5>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">npm install ejs-locals --save<\/pre>\n<p>\u3053\u3061\u3089\u3092\u4f7f\u3046\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>ejs\u3068ejs-locals \uff1f\uff1f\u3046\u30fc\u3093\u3002\u3002\u3068\u3001\u3082\u3084\u3082\u3084\u3057\u3066\u3044\u308b\u4e2d\u3001\u7206\u901f\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30a8\u30f3\u30b8\u30f3\u300cECT\u300d\u3092\u5229\u7528\u3057\u3066\u307f\u305f\u306e\u3067\u3059\u304c\u3001<\/p>\n<p>\u78ba\u304b\u306b\u4f53\u611f\u3067\u304d\u307b\u3069\u306e\u300c\u7206\u901f\u300d\u5177\u5408\u3067 \u3001&lt;% extend &#8216;\u30d5\u30a1\u30a4\u30eb\u540d&#8217; %&gt;\u3067\u3001\u30b5\u30af\u3063\u3068extend\u3082\u53ef\u80fd\u3060\u3057\u3001\u3068\u3066\u3082\u4f7f\u3044\u3084\u3059\u3044\u306e\u3067\u4f7f\u3063\u3066\u307f\u308b\u3053\u3068\u306b\u3057\u307e\u3057\u305f\u3002<\/p>\n<h4>node.js \u5404\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8 \u30d9\u30f3\u30c1\u30de\u30fc\u30af<\/h4>\n<p><strong>Jade<\/strong><\/p>\n<p><a href=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/a0be079d88bfd3bac48d2d1955746a97.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/a0be079d88bfd3bac48d2d1955746a97.png\" alt=\"\" title=\"\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2014-03-16 6.53.39\" width=\"201\" height=\"108\" class=\"alignnone size-full wp-image-5175\" \/><\/a><\/p>\n<p><strong>EJS<\/strong><\/p>\n<p><a href=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/4ba952af4d4c9a4256be609799b6e98d.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/4ba952af4d4c9a4256be609799b6e98d.png\" alt=\"\" title=\"\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2014-03-16 6.53.45\" width=\"198\" height=\"107\" class=\"alignnone size-full wp-image-5176\" \/><\/a><\/p>\n<p><strong>ECT<\/strong><\/p>\n<p><a href=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/69c1ae7d755a634ee9a32449ffe90042.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/69c1ae7d755a634ee9a32449ffe90042.png\" alt=\"\" title=\"\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2014-03-16 6.53.54\" width=\"185\" height=\"107\" class=\"alignnone size-full wp-image-5177\" \/><\/a><\/p>\n<p>\u78ba\u304b\u306b\u7fa4\u3092\u629c\u3044\u3066\u7206\u901f\uff01\uff01<\/p>\n<h4>express \u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h4>\n<p>\u4f55\u306f\u3068\u3082\u3042\u308c\u3001\u4f7f\u3063\u3066\u307f\u307e\u3057\u3087\u3046\u3002\u307e\u305aexpress\u3092npm\u30b3\u30de\u30f3\u30c9\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002<\/p>\n<p>\u524d\u56de\u306e<\/p>\n<h3><a href=\"https:\/\/www.webcyou.com\/?p=4160\">\u30b5\u30fc\u30d0\u30fc\u30b5\u30a4\u30c9Javascript node.js express\u3084\u3089npm\u3084\u3089<\/a><\/h3>\n<p>\u306b\u3082\u8a18\u8f09\u3057\u3066\u3044\u308b\u65b9\u6cd5\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">npm install -g express<\/pre>\n<p>\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3002\uff08express\u306f\u30d1\u30c3\u30b1\u30fc\u30b8\u540d\u3002express\u306e\u5834\u5408\u306a\u306e\u3067express\uff09<\/p>\n<p>\u30aa\u30d7\u30b7\u30e7\u30f3-g\u304c\u306a\u3044\u3068\u3001\u5b9f\u884c\u3057\u3066\u3044\u308b\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u4e0b\u306b<strong>\u201cnode_modules\u201d<\/strong>\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u4f5c\u308a\u3001\u305d\u3053\u306b\u30d1\u30c3\u30b1\u30fc\u30b8\u304c\u5165\u308a\u307e\u3059\u3002<\/p>\n<p>\u30aa\u30d7\u30b7\u30e7\u30f3-g\u3092\u4ed8\u3051\u308b\u3053\u3068\u306b\u3088\u3063\u3066\u3001\u4e00\u5ea6\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3067\u5168\u90e8\u306enode.js\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3067\u4f7f\u3048\u308b\u3001\u30b0\u30ed\u30fc\u30d0\u30eb\u306a\u9818\u57df\u306b\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u969b\u3001\u30d1\u30fc\u30df\u30c3\u30b7\u30e7\u30f3\u30a8\u30e9\u30fc\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3067\u304d\u305a\u3001\u30a8\u30e9\u30fc\u304c\u51fa\u3066\u3057\u307e\u3046\u5834\u5408\u306f\u3001sudo\u30b3\u30de\u30f3\u30c9\u3092\u5229\u7528\u3057\u3066\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">sudo\u00a0npm install -g express<\/pre>\n<p>password\u3092\u6c42\u3081\u3089\u308c\u307e\u3059\u306e\u3067\u3001PC\u306e\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u5165\u529b\u3002\u30ea\u30bf\u30fc\u30f3\u3002<\/p>\n<h4>ect\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h4>\n<p>ect\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u306f\u4f8b\u306e\u5982\u304f\u3001npm\u30b3\u30de\u30f3\u30c9\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u304c\u51fa\u6765\u307e\u3059\u3002<\/p>\n<p>npm install ect express\u540c\u69d8\u3001\u30aa\u30d7\u30b7\u30e7\u30f3-g\u3092\u4ed8\u3051\u308c\u3070\u30b0\u30ed\u30fc\u30d0\u30eb\u9818\u57df\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">npm install -g ect<\/pre>\n<p>\u307e\u305f\u3001\u30d1\u30fc\u30df\u30c3\u30b7\u30e7\u30f3\u30a8\u30e9\u30fc\u304c\u51fa\u308b\u5834\u5408\u306fsudo\u30b3\u30de\u30f3\u30c9\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">sudo npm install -g ect<\/pre>\n<p>\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u6c42\u3081\u3089\u308c\u307e\u3059\u306e\u3067\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u5165\u529b\u3057\u30ea\u30bf\u30fc\u30f3\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/6835170ae49aca6620d068ac26373cb4.png\" alt=\"\" title=\"\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2014-03-16 8.35.33\" width=\"398\" height=\"139\" class=\"alignnone size-full wp-image-5178\" srcset=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/6835170ae49aca6620d068ac26373cb4.png 398w, https:\/\/www.webcyou.com\/wp-content\/uploads\/6835170ae49aca6620d068ac26373cb4-300x104.png 300w\" sizes=\"auto, (max-width: 398px) 100vw, 398px\" \/><\/p>\n<p>\u3053\u306e\u3088\u3046\u306a\u611f\u3058\u306b\u306a\u308c\u3070\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u5b8c\u4e86\u3002<\/p>\n<h4>ect \u5229\u7528\u65b9\u6cd5<\/h4>\n<p>\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u4f5c\u6210\u3057\uff08\u4eca\u56de\u306fect-test\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u4f5c\u6210\u3057\u3066\u3044\u307e\u3059\u3002\uff09\u79fb\u52d5\u3002<\/p>\n<p>express\u30b3\u30de\u30f3\u30c9\u3067app &#8211;ect\u3068\u30b3\u30de\u30f3\u30c9\u3057\u3066\u307f\u305f\u3068\u3053\u308d\u3001<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">express app --ect<\/pre>\n<p><a href=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/b61b0d538d29d3279e6e994d3b32eeba.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/b61b0d538d29d3279e6e994d3b32eeba.png\" alt=\"\" title=\"\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2014-03-16 8.39.38\" width=\"409\" height=\"315\" class=\"alignnone size-full wp-image-5179\" srcset=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/b61b0d538d29d3279e6e994d3b32eeba.png 409w, https:\/\/www.webcyou.com\/wp-content\/uploads\/b61b0d538d29d3279e6e994d3b32eeba-300x231.png 300w\" sizes=\"auto, (max-width: 409px) 100vw, 409px\" \/><\/a><\/p>\n<p>\u3069\u3046\u3084\u3089\u3001\u30c7\u30d5\u30a9\u30eb\u30c8\u306e<strong>Jade\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8<\/strong>\u304c\u4f5c\u6210\u3055\u308c\u305f\u3088\u3046\u3067\u3059\u3002<\/p>\n<p>ect\u306fejs\u306b\u8a18\u8ff0\u304c\u8fd1\u3057\u3044\u306e\u3067\u3001<strong>\u4e00\u65e6\u306f ejs\u30aa\u30d7\u30b7\u30e7\u30f3\u3067\u4f5c\u6210<\/strong>\u3057\u305f\u65b9\u304c\u3044\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">express app --ejs<\/pre>\n<p><a href=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/364b2725d4d4c09cc70a45233c089e73.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/364b2725d4d4c09cc70a45233c089e73.png\" alt=\"\" title=\"\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2014-03-16 8.42.57\" width=\"210\" height=\"119\" class=\"alignnone size-full wp-image-5180\" \/><\/a><\/p>\n<p>\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u751f\u6210\u3057\u3001\u300cpackage.json\u300d\u3092\u7de8\u96c6\u3002<\/p>\n<p><strong>package.json<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">{\r\n    \"name\": \"application-name\",\r\n    \"version\": \"0.0.1\",\r\n    \"private\": true,\r\n    \"scripts\": {\r\n        \"start\": \"node app.js\"\r\n    },\r\n    \"dependencies\": {\r\n        \"express\": \"3.5.0\",\r\n        \"ect\": \"*\"\r\n    }\r\n}\r\n<\/pre>\n<p>\u306b\u5909\u66f4\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u3053\u306e\u72b6\u614b\u3067\u3001<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">npm install<\/pre>\n<p>\u3092\u884c\u3046\u3068\u3001<strong>express\u3001ect\u304c\u542b\u307e\u308c\u305f\u300cnode_modules\u300d\u30c7\u30a3\u30ec\u30af\u30c8\u30ea<\/strong>\u304c\u751f\u6210\u3055\u308c\u307e\u3059\u3002<\/p>\n<p><a href=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/44023d0b1f28c174bdb9105e9bf72adc.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/44023d0b1f28c174bdb9105e9bf72adc.png\" alt=\"\" title=\"\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2014-03-16 10.03.09\" width=\"179\" height=\"80\" class=\"alignnone size-full wp-image-5183\" \/><\/a><\/p>\n<h5>app.js<\/h5>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">var ECT = require('ect'); \/\/ ECT \u8aad\u307f\u8fbc\u307f\r\napp.engine('ect', ECT({ watch: true, root: __dirname + '\/views', ext: '.ect' }).render);\r\napp.set('view engine', 'ect');<\/pre>\n<p>app.js\u3092\u7de8\u96c6\u3057\u307e\u3059\u3002<\/p>\n<p>\u4e0a\u8a18\u306e3\u884c\u3092\u542b\u3081\u307e\u3059\u3002app.set(&#8216;view engine&#8217;, &#8216;ect&#8217;);\u306f\u3001app.set(&#8216;view engine&#8217;, &#8216;ejs&#8217;);\u3092\u5909\u66f4\u3057\u307e\u3059\u3002<\/p>\n<p>\u3082\u308d\u3082\u308d\u542b\u3093\u3060\u8a18\u8ff0\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<h5>app.js<\/h5>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">var express = require('express');\r\nvar routes = require('.\/routes');\r\nvar user = require('.\/routes\/user');\r\nvar http = require('http');\r\nvar path = require('path');\r\nvar ECT = require('ect'); \/\/ ECT \u8aad\u307f\u8fbc\u307f\r\n\r\nvar app = express();\r\n\r\n\/\/ ECT \u74b0\u5883\u8a2d\u5b9a\r\napp.engine('ect', ECT({ watch: true, root: __dirname + '\/views', ext: '.ect' }).render);\r\n\r\n\/\/ all environments\r\napp.set('port', process.env.PORT || 3000);\r\napp.set('view engine', 'ect');\r\napp.use(express.favicon());\r\napp.use(express.logger('dev'));\r\napp.use(express.json());\r\napp.use(express.urlencoded());\r\napp.use(express.methodOverride());\r\napp.use(app.router);\r\napp.use(express.static(path.join(__dirname, 'public')));\r\n\r\n\/\/ development only\r\nif ('development' == app.get('env')) {\r\n    app.use(express.errorHandler());\r\n}\r\n\r\napp.get('\/', routes.index);\r\napp.get('\/users', user.list);\r\n\r\nhttp.createServer(app).listen(app.get('port'), function(){\r\n    console.log('Express server listening on port ' + app.get('port'));\r\n});<\/pre>\n<\/p>\n<p>\u7d9a\u3044\u3066\u3001index.ejs\u3092\u5909\u66f4\u3057\u307e\u3059\u3002<\/p>\n<p>\u62e1\u5f35\u5b50\u3092ect\u306b\u5909\u66f4\u3057\u307e\u3059\u3002<\/p>\n<p><a href=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/71079416324cc0981d7e4f6c3f9da5fb.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/71079416324cc0981d7e4f6c3f9da5fb.png\" alt=\"\" title=\"\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2014-03-16 9.38.05\" width=\"139\" height=\"46\" \/><\/a><\/p>\n<p>\u5909\u66f4\u3057\u305findex.ect\u306b\u306f ejs\u7528\u306e\u8a18\u8ff0\u304c\u3042\u308a\u307e\u3059\u306e\u3067\u3001\u5909\u66f4\u3057\u307e\u3059\u3002<\/p>\n<p>&lt;%= title %&gt;<\/p>\n<p>\u2193<\/p>\n<p>&lt;%= @title %&gt;<\/p>\n<p>\u3053\u306e\u3088\u3046\u306b\u3001ect\u3067\u306f\u30d1\u30e9\u30e1\u30fc\u30bf\u306b\u306f@\u3092\u4ed8\u4e0e\u3057\u307e\u3059\u3002<\/p>\n<p>\u307e\u305f\u3001\u300c=\u300d\u3092\u4ed8\u4e0e\u3059\u308b\u3053\u3068\u3067\u3001\u30d1\u30e9\u30e1\u30fc\u30bf\u53d7\u3051\u53d6\u308b\u4e8b\u304c\u51fa\u6765\u307e\u3059\u3002<\/p>\n<h5>index.ect<\/h5>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">&lt;!DOCTYPE html&gt;\r\n&lt;html&gt; \r\n&lt;head&gt; \r\n    &lt;title&gt;&lt;%= @title %&gt;&lt;\/title&gt;\r\n    &lt;link rel='stylesheet' href='\/stylesheets\/style.css' \/&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n&lt;h1&gt;&lt;%= @title %&gt;&lt;\/h1&gt;\r\n&lt;p&gt;Welcome to &lt;%= @title %&gt;&lt;\/p&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">node app.js<\/pre>\n<p>\u3067\u8d77\u52d5\u3057\u3001localhost:3000\u306b\u30a2\u30af\u30bb\u30b9\u3002<\/p>\n<p>\u4ee5\u4e0b\u306e\u69d8\u306b\u8868\u793a\u51fa\u6765\u308c\u3070\u4e00\u65e6\u6210\u529f\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><a href=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/cda7018d2114e3dbb9d2f2e7561c5e4a.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/cda7018d2114e3dbb9d2f2e7561c5e4a.png\" alt=\"\" title=\"\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2014-03-16 9.49.07\" width=\"193\" height=\"101\" class=\"alignnone size-full wp-image-5182\" \/><\/a><\/p>\n<h4>ect \u307e\u3068\u3081\u3001\u6d3b\u7528\u65b9\u6cd5<\/h4>\n<h5>Output\uff1a\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u51fa\u529b<\/h5>\n<table class=\"articleTable\">\n<tbody>\n<tr>\n<th>&lt;%- @key %&gt;<\/th>\n<td>\u30a8\u30b9\u30b1\u30fc\u30d7\u51e6\u7406\u3092\u305b\u305a\u306b\u51fa\u529b<\/td>\n<\/tr>\n<tr>\n<th>&lt;%= @key %&gt;<\/th>\n<td>\u30a8\u30b9\u30b1\u30fc\u30d7\u51e6\u7406\u3092\u3057\u3066\u51fa\u529b<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h5>Inheritance: \u7d99\u627f<\/h5>\n<p>\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u7d99\u627f\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u5168\u4f53\u306e\u69cb\u9020\u306b\u3042\u305f\u308b\u90e8\u5206\uff08\u5171\u901a\u3067\u5229\u7528\u3059\u308b\u90e8\u5206\uff09\u3092\u89aa\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3068\u3057\u3001<\/p>\n<p>\u305d\u306e\u4e2d\u306e\u4e00\u90e8\u306e\u30d6\u30ed\u30c3\u30af\u90e8\u5206\u306e\u307f\u3092\u5b50\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3067\u4e0a\u66f8\u304d\u3059\u308b\u3068\u3044\u3063\u305f\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<table class=\"articleTable\">\n<tbody>\n<tr>\n<th>&lt;% content %&gt;<\/th>\n<td>\n<p>\u89aa\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u5074\u306b\u8a18\u8ff0\u3002<br \/>\u5b50\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3067\u4e0a\u66f8\u304d\u3059\u308b\u30d7\u30ec\u30fc\u30b9\u30db\u30eb\u30c0\u306b\u306a\u308b\u3002<\/p>\n<\/td>\n<\/tr>\n<tr>\n<th>&lt;% content &#8216;\u30d6\u30ed\u30c3\u30af\u540d&#8217; %&gt;<\/th>\n<td>\n<p>\u30d6\u30ed\u30c3\u30af\u540d\u3092\u4ed8\u4e0e\u3059\u308b\u3053\u3068\u3067\u3001<br \/>\u5c0f\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u5074\u304b\u3089\u4efb\u610f\u306b\u547c\u3073\u51fa\u305b\u307e\u3059\u3002<\/p>\n<\/td>\n<\/tr>\n<tr>\n<th>&lt;% extend \u2018example.ect\u2019 %&gt;<\/th>\n<td>\u5b50\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u5074\u304b\u3089 extend \u3067 <br \/>\u7d99\u627f\u3059\u308b\u89aa\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306e\u30d5\u30a1\u30a4\u30eb\u540d\u3092\u6307\u5b9a\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h5>Partials: \u5225\u30d5\u30a1\u30a4\u30eb\u3092\u8aad\u307f\u8fbc\u307f<\/h5>\n<p>\u5225\u30d5\u30a1\u30a4\u30eb\u3092\u8aad\u307f\u8fbc\u3080\u6642\u306f\u3001<code>include<\/code>\u00a0\u3092\u4f7f\u3044\u307e\u3059\u3002<\/p>\n<table class=\"articleTable\">\n<tbody>\n<tr>\n<th>&lt;% include \u2018example.ect\u2019 %&gt;<\/th>\n<td>\u30a4\u30f3\u30af\u30eb\u30fc\u30c9\u3057\u305f\u3044\u30d5\u30a1\u30a4\u30eb\u540d\u3092\u6307\u5b9a\u3059\u308b<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h5><span>Blocks: \u30d6\u30ed\u30c3\u30af\u306e\u4f7f\u3044\u65b9<\/span><\/h5>\n<p>\u7d99\u627f\u3067\u4f7f\u7528\u3057\u305f\u00a0<code>&lt;% content %&gt;<\/code>\u00a0\u306e\u4ed6\u306b\u3001\u4efb\u610f\u306e\u540d\u524d\u3092\u3064\u3051\u305f\u8907\u6570\u306e\u30d7\u30ec\u30fc\u30b9\u30db\u30eb\u30c0\u3092\u5229\u7528\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<table class=\"articleTable\">\n<tbody>\n<tr>\n<th>\n<p>&lt;% content \u2018example\u2019 %&gt;<\/p>\n<\/th>\n<td>\u89aa\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u5074\u306b\u66f8\u304f\u3002<br \/>\u30d7\u30ec\u30fc\u30b9\u30db\u30eb\u30c0\u306b\u4efb\u610f\u306e\u540d\u524d\u3092\u6307\u5b9a\u3059\u308b\u3002<\/td>\n<\/tr>\n<tr>\n<th>\n<p>&lt;% block \u2018example\u2019 : %&gt;<\/p>\n<p>&lt;% end %&gt;<\/p>\n<\/th>\n<td>\u5b50\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u5074\u306b\u66f8\u304f\u3002<br \/>\u89aa\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306e\u30d7\u30ec\u30fc\u30b9\u30db\u30eb\u30c0\u540d\u3092\u6307\u5b9a\u3059\u308b\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h5>Conditions: \u6761\u4ef6\u5206\u5c90<\/h5>\n<p>CoffeeScript \u306e\u30b7\u30f3\u30bf\u30c3\u30af\u30b9\u3068\u540c\u69d8\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><a href=\"http:\/\/coffeescript.org\/\" target=\"_blank\">CoffeeScript<\/a><\/p>\n<table class=\"articleTable\">\n<tbody>\n<tr>\n<th>\n<p>&lt;% \u6761\u4ef6\u6587: %&gt;<\/p>\n<p>&lt;% else: %&gt;<\/p>\n<p>&lt;% end %&gt;<\/p>\n<\/th>\n<td>\u6761\u4ef6\u6587\u3084 else \u306e\u5f8c\u306e\u00a0: \u3092\u4ed8\u4e0e\u3002<br \/>if\u6587\u7d42\u4e86\u7b87\u6240\u306b\u00a0<code>&lt;% end %&gt;<\/code>\u00a0\u3092\u4ed8\u4e0e\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>\u30b5\u30f3\u30d7\u30eb\u4f8b<\/h4>\n<p>extend\u3092\u7528\u3044\u305f\u7d99\u627f\u4f8b\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u4f8b\uff1a<\/p>\n<p><strong>layout.ect<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">&lt;!DOCTYPE html&gt;\r\n&lt;html lang=&quot;ja&quot;&gt;\r\n&lt;head&gt;&lt;meta charset=&quot;UTF-8&quot;&gt;\r\n    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no&quot;&gt;\r\n    &lt;title&gt;&lt;%= @title %&gt;&lt;\/title&gt;\r\n    &lt;link rel=&quot;stylesheet&quot; href=&quot;\/css\/style.css&quot;\/&gt;\r\n    &lt;% content 'scripts' %&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n&lt;header&gt;&lt;\/header&gt;\r\n&lt;% content %&gt;\r\n&lt;footer&gt;&lt;\/footer&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<p>\u5171\u901a\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8 layout.ect \u3092\u4f5c\u6210\u3002<\/p>\n<p>extend\u3067\u547c\u3073\u51fa\u3057\u3001\u5404\u30da\u30fc\u30b8\u306e\u30b3\u30f3\u30c6\u30f3\u30c4\u306f\u00a0\uff1c% content %\uff1e\u306b\u633f\u5165\u3055\u308c\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<p>\uff1c% content &#8216;scripts&#8217;%\uff1e\u3068\u4efb\u610f\u306e\u30d6\u30ed\u30c3\u30af\u540d\u3092\u4ed8\u4e0e\u3059\u308b\u3053\u3068\u3067\u3067\u4efb\u610f\u306b\u547c\u3073\u51fa\u3059\u4e8b\u304c\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<p><strong>index.ect<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">&lt;% extend 'layout.ect' %&gt;\r\n&lt;section&gt;\r\n    &lt;h1&gt;&lt;%= @title %&gt;&lt;\/h1&gt;\r\n    &lt;p&gt;Hello!&lt;\/p&gt;\r\n&lt;\/section&gt;<\/pre>\n<p>\uff1c\uff05 extend &#8216;layout.ect&#8217; \uff05\uff1e\u3067\u5148\u7a0b\u4f5c\u6210\u3057\u305f\u3001layout.ect\u3092\u547c\u3073\u51fa\u3057\u305d\u306e\u5f8c\u306e\u8a18\u8ff0\u306f<\/p>\n<p>\uff1c% content\u00a0%\uff1e\u306b\u51fa\u529b\u3055\u308c\u307e\u3059\u3002<\/p>\n<p><strong>page.ect<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">&lt;% extend 'layout.ect' %&gt;\r\n&lt;% block 'scripts' : %&gt;\r\n&lt;script type=&quot;text\/javascript&quot;&gt;\r\n    var params = { title: '&lt;%= @title %&gt;' };\r\n&lt;\/script&gt;\r\n&lt;script src=&quot;..\/js\/page.js&quot; type=&quot;text\/javascript&quot;&gt;&lt;\/script&gt;\r\n&lt;% end %&gt;\r\n&lt;section&gt;&lt;\/section&gt;<\/pre>\n<\/p>\n<p>\u5404\u30da\u30fc\u30b8\u3067\u3001\u3053\u306e\u30da\u30fc\u30b8\u3060\u3051\u306fscript\u3092\u5909\u3048\u305f\u3044\u3001\u56fa\u6709\u306escript\u3092\u8aad\u307f\u8fbc\u307f\u305f\u3044\u3068\u8a00\u3063\u305f\u3068\u304d\u306f<\/p>\n<p>\u5148\u307b\u3069\u4f5c\u6210\u3057\u305f\uff1c% content &#8216;scripts&#8217;%\uff1e\u3092\u3000&lt;% block &#8216;scripts&#8217; : %&gt;\u3067\u547c\u3073\u51fa\u3057<\/p>\n<p>\u5909\u66f4\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<p>\uff1c% content &#8216;scripts&#8217;%\uff1e<\/p>\n<p>&lt;% block &#8216;scripts&#8217; : %&gt;<\/p>\n<p>&lt;% end %&gt;<\/p>\n<h5>if\u30fbfor\u6587\u4f8b<\/h5>\n<p>if\u6587\u3001for\u6587\u3092\u7528\u3044\u305f\u4f8b\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u4f8b\uff1a<\/p>\n<p><strong>routes\/index.js<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">exports.index = function(req, res){ res.render('index', { \r\n    title: 'Express',\r\n    links: &#x5B; \r\n      { name : 'Google', url : 'http:\/\/google.com\/' },\r\n      { name : 'Facebook', url : 'http:\/\/facebook.com\/' },\r\n      { name : 'Twitter', url : 'http:\/\/twitter.com\/' } \r\n      ] \r\n  });\r\n};<\/pre>\n<\/p>\n<p>routes\/index.js\u306b\u30ea\u30f3\u30af\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210\u3002<\/p>\n<p><strong>index.ect<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">&lt;% linkHelper = (link) -&gt; %&gt;\r\n  &lt;li&gt;&lt;a href=&quot;&lt;%- link.url %&gt;&quot;&gt;&lt;%- link.name %&gt;&lt;\/a&gt;&lt;\/li&gt;\r\n&lt;% end %&gt;\r\n&lt;% if @links?.length : %&gt; \r\n  &lt;ul&gt; \r\n      &lt;% for link in @links : %&gt;\r\n      &lt;%- linkHelper link %&gt;\r\n      &lt;% end %&gt;\r\n  &lt;\/ul&gt; &lt;% else : %&gt;\r\n  &lt;p&gt;List is empty&lt;\/p&gt;\r\n&lt;% end %&gt;<\/pre>\n<\/p>\n<p>\u4e0a\u8a18\u306e\u8a18\u8ff0\u3067\u547c\u3073\u51fa\u3059\u4e8b\u304c\u53ef\u80fd\u3068\u306a\u3063\u3066\u304a\u308a\u307e\u3059\u3002<\/p>\n<p><strong>\u51fa\u529b<\/strong><\/p>\n<p><a href=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/dcbeaa245a5f52e77cc2bbe84ead0651.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/dcbeaa245a5f52e77cc2bbe84ead0651.png\" alt=\"\" title=\"\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2014-03-16 10.25.06\" width=\"160\" height=\"82\" class=\"alignnone size-full wp-image-5184\" \/><\/a><\/p>\n<p>\u7d30\u304b\u304f\u898b\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">&lt;% linkHelper = (link) -&gt; %&gt;\r\n    &lt;li&gt;&lt;a href=\u201d&lt;%- link.url %&gt;\u201d&gt;&lt;%- link.name %&gt;&lt;\/a&gt;&lt;\/li&gt;\r\n&lt;% end %&gt;<\/pre>\n<p>\u4e0a\u8a18\u306e\u90e8\u5206\u3067 \u51fa\u529b\u3059\u308b\u5185\u5bb9\u306e\u5b9a\u7fa9\u3092\u884c\u306a\u3063\u3066\u304a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">&lt;% if @links?.length : %&gt;<\/pre>\n<p>\u00a0links\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u304c\u5b58\u5728\u3059\u308c\u3070\u4ee5\u4e0b\u306efor\u6587\u3092\u5b9f\u884c\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">&lt;% for link in @links : %&gt; &lt;%- linkHelper link %&gt; &lt;% end %&gt;<\/pre>\n<p>\u5909\u6570link \u306b@links\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u4ee3\u5165\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">&lt;%- linkHelper link %&gt;<\/pre>\n<p>\u4e0a\u8a18\u3067\u5b9a\u7fa9\u3057\u305f\u51fa\u529b\u3059\u308b\u5185\u5bb9\u306b\u305d\u308c\u305e\u308c\u4ee3\u5165\u3055\u308c\u51fa\u529b\u3057\u307e\u3059\u3002<\/p>\n<h4>\u6700\u5f8c\u306b&#8230;<\/h4>\n<p>\u3068\u3044\u3063\u305f\u611f\u3058\u3067\u3001\u7206\u901f\u3067\u975e\u5e38\u306b\u4f7f\u3044\u3084\u3059\u3044\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30a8\u30f3\u30b8\u30f3\u3068\u306a\u3063\u3066\u304a\u308a\u307e\u3059\u3002<\/p>\n<p>\u6b21\u56de\u306f\u5b9f\u969b\u306b\u5229\u7528\u3057\u305f node \u00a0webApp\u3092\u7d39\u4ecb\u3055\u305b\u3066\u9802\u304d\u307e\u3059\u3002<\/p>\n<p>\u3067\u306f\u3067\u306f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>node.js\u3067webApp\u3092\u4f5c\u6210\u3059\u308b\u969b\u3001Express\u3092\u7528\u3044\u305f\u69d8\u3005\u306a\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30a8\u30f3\u30b8\u30f3\u304c\u5b58\u5728\u3057\u307e\u3059\u3002 \u6709\u540d\u3068\u3053\u308d\u3067\u3001\u300cEJS\u300d\u3084\u300cjade\u300d\u7b49\u3005\u3068\u3042\u308b\u306e\u3067\u3059\u304c\u3001\u305d\u306e\u4e2d\u3067\u3082\u7fa4\u3092\u629c\u3044\u3066\u7206\u901f\u3068\u3044\u308f\u308c\u3066\u3044\u308b\uff08\u3046\u305f\u3063\u3066\u3044\u308b\uff09\u30c6 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[47,160,39,178,78,114,118],"class_list":["post-5173","post","type-post","status-publish","format-standard","hentry","category-javascript","tag-javascript-2","tag-node-js","tag-39","tag-178","tag-78","tag-114","tag-118"],"_links":{"self":[{"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/posts\/5173","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5173"}],"version-history":[{"count":12,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/posts\/5173\/revisions"}],"predecessor-version":[{"id":5196,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/posts\/5173\/revisions\/5196"}],"wp:attachment":[{"href":"https:\/\/www.webcyou.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5173"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5173"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5173"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}