mustache
以åãmustacheã®è¨äºãæ¸ãã¾ããããåå¼·ãç´ããã®ã§æ¹ãã¦è¨äºã«ãã¾ããä»åã¯ãHTMLã¨JavaScriptã®åé¢ã«ç¦ç¹ãå½ã¦ã¦æ¸ãã¾ãã HTMLãæ¿å ¥ããä¾ HTMLã®ãã³ãã¬ã¼ãå HTMLã³ã¼ãã®åé¢ ã¾ã¨ã åè HTMLãæ¿å ¥ããä¾ idå±æ§ãresultã§ããè¦ç´ ã®åâ¦
å½ããã°ã§ç´¹ä»ããmustacheã®è¨äºãä¸è¦§ã«ã¾ã¨ãã¾ããã ããããmustacheã«åºä¼ã£ãã®ã¯ãVue.jsã®åå¼·æã§ãããç¥ããªããã¨ã§ããã®ã§ããããæ©ã«åå¼·ãã¾ããã mustacheã®è¨äºã¾ã¨ã mustacheå ¥é:Rubyç mustacheå ¥é:JavaScriptç åèãµã¤ã musâ¦
ã¬ã³ãã¼é¨åã§ãã¼ã¿ãæå®ãã¦ããã¨ãããããã¾ãããããå¤é¨ãã¡ã¤ã«ã¨ãã¦èªã¿è¾¼ãããã«å¤æ´ãã¾ããããã§ã¯ããã¼ã¿ãJSONPãã¡ã¤ã«ã¨ãã¦ç¨æãã¾ãã ä½æãããã¡ã¤ã« JSONPã§ãã¼ã¿ãèªã¿è¾¼ã ã¾ã¨ã åèãµã¤ã ä½æãããã¡ã¤ã« HTMLãã¡ã¤â¦
ååã¯ãå ¬å¼ãµã¤ãã®ãµã³ãã«ã³ã¼ãããã®ã¾ã¾å©ç¨ãã¦mustacheã®åä½ç¢ºèªããã¾ãããä»åã¯ãæ°ã«ãªãé¨åã®ã³ã¼ããæ´çãã¦ããããã¨æãã¾ãã ä½æãããã¡ã¤ã« ãã³ãã¬ã¼ããJavaScriptã«è¨è¿°ããããã«å¤æ´ãã å¤æ´å å¤æ´å¾ ã¾ã¨ã ä½æãããâ¦
mustacheã®å°å ¥ã«ã¤ãã¦æ¸ãã¾ããmustacheã¯ããã³ãã¬ã¼ãã¨ã³ã¸ã³ã§ããè²ã ãªè¨èªã§å©ç¨ã§ããã¨ãããã¨ãªã®ã§ãä¸åº¦å¦ç¿ãã¦ããã¨ä»ã§ã使ããã®ã§åå¼·ãã¦ããã«è¶ãããã¨ã¯ãªãã¨æãã¾ããä»åã¯ãJavaScriptã§mustacheãåå¼·ãã¾ãã å ¬å¼ãµã¤ãâ¦
ãã³ãã¬ã¼ããã¡ã¤ã«ã®ä¸èº«ãå¤ããªãã¨ã³ã¼ãã®è¦éããæªããªãã¾ããããã§ãã³ãã¬ã¼ãã®ä¸é¨åãé¨ååãã¦ãå¥ãã¡ã¤ã«ã«åãåºãæ¹æ³ãè¦ã¦ããã¾ãã ä½æãããã¡ã¤ã« ãã³ãã¬ã¼ãã®é¨åå é¨ååã®ç¢ºèª ã¾ã¨ã åèãµã¤ã ä½æãããã¡ã¤ã« ãã¼â¦
ãã¼ã¿ãããéãä¸è¦§è¡¨ç¤ºããæ¹æ³ãè¦ã¦ããã¾ãã ä½æãããã¡ã¤ã« è¤éãªãã¼ã¿ã®åãè¾¼ã¿ã®ç¢ºèª ã¾ã¨ã åèãµã¤ã ä½æãããã¡ã¤ã« ãã¼ã¿ãã¡ã¤ã«:data.yml ãã³ãã¬ã¼ããã¡ã¤ã«:template.mustache ãã¼ã¿ãã¡ã¤ã«ã¨ãã³ãã¬ã¼ããã¡ã¤ã«ã以ä¸ã®ãâ¦
ã»ã¯ã·ã§ã³ã¨ããå¡ãä½ããçå½å¤ã®å¤ã«ãã£ã¦è¡¨ç¤ºãåºãåãã¾ãã ä½æãããã¡ã¤ã« çå½å¤ã«ãã表示ã®ç¢ºèª çå½å¤ã«å¿ãã¦ãã³ãã¬ã¼ãã®è¡¨ç¤ºãåãæ¿ãã çå½å¤ã«ãã表示ã®åãæ¿ãã®ç¢ºèª ã¾ã¨ã åèãµã¤ã ä½æãããã¡ã¤ã« ãã¼ã¿ãã¡ã¤ã«:data.yâ¦
åºåãè¨å·ã{{}}ããä»ã®ãã®ã«å¤æ´ããæ¹æ³ãè¦ã¦ããã¾ãã ä½æãããã¡ã¤ã« åºåãè¨å·ã®å¤æ´ åºåãè¨å·å¤æ´ã®ç¢ºèª ã¾ã¨ã åèãµã¤ã ä½æãããã¡ã¤ã« ãã¼ã¿ãã¡ã¤ã«:data.yml ãã³ãã¬ã¼ããã¡ã¤ã«:template.mustache ãã¼ã¿ãã¡ã¤ã«ã¨ãã³ãã¬ã¼â¦
ãã³ãã¬ã¼ãã«HTMLã¿ã°ãåãè¾¼ãæ¹æ³ãè¦ã¦ããã¾ããå°ã注æãå¿ è¦ãªã®ã§ããã¡ããåããã¦æ¸ãã¾ãã ä½æãããã¡ã¤ã« HTMLã¿ã°ã®åã込㿠HTMLã¿ã°ã®åãè¾¼ã¿ã®ç¢ºèª ã¾ã¨ã åèãµã¤ã ä½æãããã¡ã¤ã« ãã¼ã¿ãã¡ã¤ã«:data.yml ãã³ãã¬ã¼ããã¡ã¤â¦
mustacheã®åºæ¬çãªè¨è¿°ãè¦ã¦ããã¾ããã¾ãããã¼ã¿ãã¡ã¤ã«ã¨ãã³ãã¬ã¼ããã¡ã¤ã«ãç¨æãã¾ãããã¼ã¿ãã¡ã¤ã«ã«ãã¼ã¿ãããã³ãã¬ã¼ããã¡ã¤ã«ã«ãã³ãã¬ã¼ããè¨è¿°ãã¾ããmustacheã³ãã³ãã§ãã¼ã¿ããã³ãã¬ã¼ãã«åãè¾¼ã¾ãããã¨ã確èªãã¾ãã â¦
mustacheã®å°å ¥ã«ã¤ãã¦æ¸ãã¾ããmustacheã¯ããã³ãã¬ã¼ãã¨ã³ã¸ã³ã§ããè²ã ãªè¨èªã§å©ç¨ã§ããã¨ãããã¨ãªã®ã§ãä¸åº¦å¦ç¿ãã¦ããã¨ä»ã§ã使ããã®ã§åå¼·ãã¦ããã«è¶ãããã¨ã¯ãªãã¨æãã¾ããä»åã¯ãRubyã®mustacheããã±ã¼ã¸ã使ã£ã¦åå¼·ãã¾ãã â¦