ãã¤ãå¿ããããã¡ã¢ Express(Node.js)ã§å©ç¨åºæ¥ããã³ãã¬ã¼ãã¨ã³ã¸ã³ã§ectãæè¿ä½¿ã£ã¦ãã¾ããï¼ejsã®ããã«forEachæãæ¸ããã¨ããã¨å¤±æããã®ã§ã¡ã¢
ä¼¼ããããªãã¡ã¤ã«ãããããä½ãæ©ä¼ããã£ããã ãã©ãé¢åã ãå¾ããæ´æ°ããã®ã大å¤ã ããã§ãGulpã¨EJSã使ã£ã¦ãJSONãã¡ã¤ã«ã®è¨å®ãèªã¿è¾¼ãã§ããã®è¨å®ã®åã ãHTMLãã¡ã¤ã«ãçæããæ¹æ³ã¯ãªããã¨æ¢ãã¦ã¿ãã¨ããããã£ã±ãããã¾ããã aircolor.hatenablog.com ãã å人çã«ããã£ã±ãã¿ã¹ã¯ä½ãã®ã£ã¦ã©ããªãã ãã...ã¨æã£ãã®ã§ã1åã®ã¿ã¹ã¯ã«ã¾ã¨ãã¦ã¿ããã¨ã«ã ç¨æãããã® gulpã¯å ¥ãã¦ããåæãã¤ã³ã¹ãã¼ã«ã¯å²æã fs gulp-ejs gulp-rename ä¸è¨ã¯æ°ããä½ãã¾ãã pages.jsonï¼åãã¼ã¸ã®è¨å®ç¨ãã¡ã¤ã«ï¼ template.ejsï¼ãã³ãã¬ã¼ãEJSãã¡ã¤ã«ï¼ åãã¡ã¤ã«ã®è¨å® pages.json ããããã®ãã¼ã¸ã®è¨å®ãè¨è¿°ã { "pages": [ { "id": "page1", "title":
ååãHTMLãã¡ã¤ã«ãèªã¿è¾¼ãã§è¡¨ç¤ºããããã¨ãããã¨ãè¡ãã¾ããããæã£ãããé¢åããããã¨ããããã¾ããããã¡ã¤ã«ãèªã¿è¾¼ãã®ã«éåæã¡ã½ããã使ããªãã¨ãããªãããã¡ãã£ã¨ãããã¼ã¿ãHTMLã«å渡ãã¦è¡¨ç¤ºãããã®ããã¡ãã¡replaceã§ã³ã¼ããç½®æãããããªãã¨ãããªãããã£ã¨ç°¡åãªæ¹æ³ã¯ãªãã®ãï¼ã¨æã£ããã¨ã§ãããã å®ã¯ãããã¾ããããã¯ããã³ãã¬ã¼ãã¨ã³ã¸ã³ãã使ãã®ã§ããNode.jsã§ã¯ããã¾ãã¾ãªãã³ãã¬ã¼ãã¨ã³ã¸ã³ãå©ç¨ã§ãã¾ãããã£ã¨ãä¸è¬çã«ç¨ãããã¦ããã®ã¯ãEJSãã¨ãããã®ã§ãããã ã§ã¯ãEJSãã¤ã³ã¹ãã¼ã«ãã¾ããããNode.jsã«ã¯ãnpmãã¨ããããã±ã¼ã¸ç®¡çããã°ã©ã ãç¨æããã¦ãã¾ããããã使ããã¨ã§ãã³ãã³ãä¸çºã§å¿ è¦ãªã©ã¤ãã©ãªããªã³ã©ã¤ã³çµç±ã§ãã¦ã³ãã¼ããã¤ã³ã¹ãã¼ã«ã§ãã¾ãã ã³ãã³ãããã³ãããã¿ã¼ããã«ãèµ·åãã以ä¸ã®ããã«
人æ°ã®ã¿ã¹ã¯ã©ã³ãã¼ãã¼ã«ãGulp.jsãã¨ãã³ãã¬ã¼ãã¨ã³ã¸ã³ãEJSããä¸å°ã«ã JSONãã¼ã¿ããè¤æ°ãã¼ã¸ãçæã§ããä»çµã¿ãåå¿é²ãå ¼ãã¦ç´¹ä»ãã¾ãã ãã£ãã ç¾å¨é²ãã¦ããæ¡ä»¶ã§ãHTMLãéçãã¤ãããã大éã«ä½ãäºæ¡ãçºçã ããã1ãã¼ã¸ã¥ã¤ä½æã»ä¿®æ£ããã®ã¯ã¨ã«ããããã©ãããã¨æãããã®ã§ãJSONã§æ å ±ãä¸æ¬ã§ç·¨éã§ããçæãç°¡åã«åºæ¥ãããæ¹ã確ç«ãããã£ãã åæã»ããããã㨠ãµã¼ãã¯ãããã®ã使ç¨ã権éçãªåé¡ã§æ°ãã«ããã±ã¼ã¸ã®ã¤ã³ã¹ãã¼ã«ãããã¨ã¯ä¸å¯ã PHPã使ããªããµã¼ãã ã£ããããè¤è£½ã¯éçHTMLã§è¡ãå¿ è¦ãããã ä¼¼ããã¼ã¸ã1ã¤ã¥ã¤ä½æãå¾ã§ä¿®æ£ãããã®ã¯ã¨ã«ããããã©ãããã®ã§ãæ©æ¢°çã«è¡ãããã ãã¼ã¸è¤è£½ç¨ãã¼ã¿ã¯å ¨ã¦JSONãã¡ã¤ã«ã«ã¾ã¨ãããã ä»æ§ æ¸ãåºããã¼ã«ã¨ãã¦Gulp.jsã使ç¨ã ãã³ãã¬ã¼ãã¨ã³ã¸ã³ã¯EJSãæ¡
2016 - 02 - 01 éçãµã¤ãã¸ã§ãã¬ã¼ã¿ã¼ãæ¯è¼ãã¦gulp-ejsã«è¾¿ãçãã Webéçº gulp ã¹ãã³ãµã¼ã ãªã³ã¯ éçãµã¤ãã¸ã§ãã¬ã¼ã¿ã¼ï¼ã¹ã¿ãã£ãã¯ãµã¤ãã¸ã§ãã¬ã¼ã¿ã¼ï¼ãããã¤ãæ¯è¼ããå®éã«ä½¿ã£ã¦ã¿ã¦ãæçµçã« gulp-ejs ã«è¾¿ãçãã¾ããã ã¾ããgulp-ejsã«è¾¿ãçãã¾ã§ã®è©±ãå°ãã ãã ãã®å¾ãgulp-ejsã®å°å ¥æ¹æ³ãæ¸ãã¦ããã¾ãã gulp-ejsã«è¾¿ãçãã¾ã§ æåã¯smarty å ã ã¯åçãµã¤ããæ§ç¯ããããã«ã smarty ãå©ç¨ãã¦ãã¾ããã ãã¼ã¿ãã¼ã¹ã¨ã®éä¿¡ãããã³ãã¬ã¼ãã¨ã³ã¸ã³ã¨ãã¦ã®æ©è½ãå¼·åãªãã£ãã·ã¥æ©è½ãªã©ã使ããããé¨åãå¤ãã£ãã§ãã ãããããã¼ã¿ãã¼ã¹ã¨ã®éä¿¡ãä¸è¦ã§ç°¡åãªãµã¤ããä½ããããªã±ã¼ã¹ã®å ´åãã¡ãªããããããã¡ãªããï¼å°å ¥ãã¡ã³ããã³ã¹ã«æããæéï¼ã®æ¹ã大ãããªã£ãã®ã§ãç°¡åã«ä½¿ããé
gulpã使ã£ã¦EJSãã³ãã¬ã¼ããHTMLã«æ¸ãåºãæ¹æ³ã試ãã¦ã¿ãã®ã§ããã®å°å ¥æé ãªã©ãã¾ã¨ãã¦ã¿ã¾ããã EJSã«ã¤ã㦠HTMLãçæãããã³ãã¬ã¼ãã¨ã³ã¸ã³ã®ã²ã¨ã¤ Node.jsç°å¢ã§åä½ãããã³ãã¬ã¼ãã¿ã°ä¸ã®å¦çã¯JavaScriptã§è¨è¿°ã§ãã HTMLã«ãã³ãã¬ã¼ãã¿ã°ãåãè¾¼ãå½¢ãªã®ã§å¦ç¿ã³ã¹ããä½ã âãPHPã¿ãããªäºãJavaScriptã§ããã¤ã¡ã¼ã¸ Webãµã¼ãä¸ã§åçãã¼ã¸ã¨ãã¦åºåãã使ãæ¹ãæ³å®ãã¦ããã£ã½ã ãã©ããã¼ã«ã«ç°å¢ã§éçãã¼ã¸ã¨ãã¦ã®åºåãå¯è½ï¼gulp/Gruntãªã©ã¨é£æºããã¨ç°¡åããï¼ ããæ¯è¼ã«æãããã¦ããJadeã®å ´åã¯Rubyã®ãã³ãã¬ã¼ãã¨ã³ã¸ã³Hamlã«å½±é¿ãåãã¦ãããããããã³ãã¬ã¼ãã¿ã°ä»¥å¤ã®HTMLã®è¨è¿°ãé常ã¨ã¯ç°ãªãã¾ãï¼ããããç縮ææ³ï¼ã Jadeã®æ¹ãã³ã¼ãã®è¨è¿°éã¯æãããã¦ä¾¿å©ããã§ãããå¦ç¿ã³ã¹
What is EJS? What is the "E" for? "Embedded?" Could be. How about "Effective," "Elegant," or just "Easy"? EJS is a simple templating language that lets you generate HTML markup with plain JavaScript. No religiousness about how to organize things. No reinvention of iteration and control-flow. It's just plain JavaScript. Use plain JavaScript We love JavaScript. It's a totally friendly language. All
ããã«ã¡ã¯ï¼ LIGãã£ãªãã³æ¯ç¤¾ä»£è¡¨ã®ããã¨(@seito_horiguchi)ã§ãã çªç¶ã§ããã¿ãªãããEJSã£ã¦ãåãã§ããï¼ EJSã£ã¦ããã®ã¯ã§ããããªãããããããããããããã¼ã«ã§ãã¦ï¼ãã¨ã«ããã使ãã¨ã³ã¼ãã£ã³ã°ããã£ã¡ãæ©ããªããã§ããï¼ï¼ ä»åã¯ããã使ã£ã¦ãçéã§ã³ã¼ãã£ã³ã°ãããã¯ããã¯ã®å ¥éç·¨ãç´¹ä»ãããã¨æãã¾ãã EJSã¨ã¯ï¼ EJSã¯ãã³ãã¬ã¼ãã¨ã³ã¸ã³ã¨å¼ã°ãããã¼ã«ã®1ã¤ã§ãJavaScriptã®ãããªæ¸ãæ¹ãåãå ¥ãã¤ã¤HTMLãæ¸ããã¨ããç¹å¾´ãæã£ã¦ãã¾ãã ãã£ã£ã£ã£ããè¨ã表ãã¨ãSassã¨CSSã®é¢ä¿ã«è¿ãã§ãã ãEJSãã¼ã¿ã§ãã楽ãªæ¸ãæ¹ããã¦ãHTMLã«å¤æãã¦åºåããããã¨ãã§ãã¾ãã ããã使ããããã«ãªãã¨ãä¾ãã°headerãfooterãªã©ã®ãã¼ããåå²ãã¦å ±éåãããããJSã®foræã®ãããªå½ä»¤ãHTMLä¸ã§ä½¿ãã¾ã
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}