{"id":7562,"date":"2019-11-27T22:40:20","date_gmt":"2019-11-27T13:40:20","guid":{"rendered":"http:\/\/www.code-magagine.com\/?p=7562"},"modified":"2023-05-27T22:59:15","modified_gmt":"2023-05-27T13:59:15","slug":"%e3%80%90ruby-on-rails%e3%80%91slim%e3%81%a8%e3%81%af%ef%bc%9f","status":"publish","type":"post","link":"http:\/\/www.code-magagine.com\/?p=7562","title":{"rendered":"\u3010Ruby on Rails\u3011\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30a8\u30f3\u30b8\u30f3\u306e\u7a2e\u985e\uff08ERB,Haml,Slim)"},"content":{"rendered":"<h2>\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30a8\u30f3\u30b8\u30f3\u3068\u306f\uff1f<\/h2>\n<p>\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3067\u751f\u6210\u3059\u308bHTML\u753b\u9762\u3092\u76f4\u611f\u7684\u306b\u308f\u304b\u308a\u3084\u3059\u3044\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u5f62\u5f0f\u3067\u8a18\u8ff0\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<h2>ERB<\/h2>\n<p>Rails\u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30a8\u30f3\u30b8\u30f3\u3067\u3059\u3002ERB\u306e\u8a73\u7d30\u306f\u4e0b\u8a18\u306e\u8a18\u4e8b\u3067\u3082\u89e3\u8aac\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<blockquote class=\"wp-embedded-content\" data-secret=\"afC9eUeXbO\"><p><a href=\"http:\/\/www.code-magagine.com\/?p=4451\">\u3010Ruby on Rails\u3011\u30d3\u30e5\u30fc\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\uff08ERB\uff09\u306e\u8a18\u8ff0\u30eb\u30fc\u30eb<\/a><\/p><\/blockquote>\n<p><iframe class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" src=\"http:\/\/www.code-magagine.com\/?p=4451&#038;embed=true#?secret=afC9eUeXbO\" data-secret=\"afC9eUeXbO\" width=\"500\" height=\"282\" title=\"&#8220;\u3010Ruby on Rails\u3011\u30d3\u30e5\u30fc\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\uff08ERB\uff09\u306e\u8a18\u8ff0\u30eb\u30fc\u30eb&#8221; &#8212; \u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u30de\u30ac\u30b8\u30f3\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\n<p>\u305f\u3060\u3001Rails\u3092\u4f7f\u3063\u305f\u958b\u767a\u73fe\u5834\u3067\u306fERB\u3088\u308a\u3082\u3069\u3061\u3089\u304b\u3068\u3044\u3048\u3070<span style=\"color: #ff0000;\"><strong>Haml\u3084Slim<\/strong><\/span>\u3068\u3044\u3063\u305f\u5225\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30a8\u30f3\u30b8\u30f3\u3092\u63a1\u7528\u3059\u308b\u3053\u3068\u304c\u591a\u304f\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<h2>Haml<\/h2>\n<p>Haml\u306f\u4e0b\u8a18\u306e\u3088\u3046\u306b\u8a18\u8ff0\u3057\u307e\u3059\u3002ERB\u306b\u6bd4\u3079\u308b\u3068\u30c4\u30ea\u30fc\u4e0a\u3067\u69cb\u9020\u3092\u8a18\u8ff0\u3057\u3066\u3044\u308b\u306e\u3067\u7c21\u6f54\u3067\u8aad\u307f\u3084\u3059\u3044\u306e\u3067\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">%html\r\n %body\r\n  %h1= @title<\/pre>\n<h2>Slim<\/h2>\n<p>Slim\u306f\u4e0b\u8a18\u306e\u3088\u3046\u306b\u8a18\u8ff0\u3057\u307e\u3059\u3002ERB\u306b\u6bd4\u3079\u308b\u3068\u30c4\u30ea\u30fc\u4e0a\u3067\u69cb\u9020\u3092\u8a18\u8ff0\u3057\u3066\u3044\u308b\u306e\u3067\u7c21\u6f54\u3067\u8aad\u307f\u3084\u3059\u3044\u306e\u3067\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">html\r\n body\r\n  h1= @title<\/pre>\n<h3>Slim\u3092\u4f7f\u3046\u306b\u306f\uff1f<\/h3>\n<p>\u4e0b\u8a182\u3064\u306egem\u304c\u5fc5\u8981\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<ul>\n<li>slim-rails<\/li>\n<li>html2slim<\/li>\n<\/ul>\n<h4>slim-rails<\/h4>\n<p>Slim\u306e\u30b8\u30a7\u30cd\u30ec\u30fc\u30bf\u3092\u63d0\u4f9b\u3059\u308bgem\u3067\u3059\u3002<\/p>\n<h4>html2slim<\/h4>\n<p>ERB\u5f62\u5f0f\u306e\u30d5\u30a1\u30a4\u30eb\u3092slim\u5f62\u5f0f\u306b\u5909\u63db\u3057\u3066\u304f\u308c\u308berb2slim\u30b3\u30de\u30f3\u30c9\u3092\u63d0\u4f9b\u3057\u3066\u304f\u308c\u308bgem\u3067\u3059\u3002<\/p>\n<h3>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u624b\u9806<\/h3>\n<p>\u307e\u305a\u306f\u3001Gemfile\u306b\u4e0b\u8a18\u306e\u8a18\u8ff0\u3092\u8ffd\u52a0\u3059\u308b\u3002<\/p>\n<pre class=\"lang:default decode:true \">gem 'slim-rails'\r\ngem 'html2slim'<\/pre>\n<p>bundle\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3002<\/p>\n<pre class=\"lang:default decode:true\">bundle<\/pre>\n<p>bundle\u30b3\u30de\u30f3\u30c9\u306f\u3001Gemfile\u306b\u66f8\u304b\u308c\u305fgem\u53ca\u3073\u305d\u308c\u306b\u4f9d\u5b58\u3059\u308bgem\u3092\u5168\u3066\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u305f\u72b6\u614b\u306b\u3057\u3066\u304f\u308c\u307e\u3059\u3002\u30b5\u30fc\u30d0\u306e\u8d77\u52d5\u4e2d\u306e\u5834\u5408\u306f\u53cd\u6620\u3055\u305b\u308b\u306b\u306f\u518d\u8d77\u52d5\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u4eca\u5f8c\u4f5c\u6210\u3055\u308c\u308b\u30d3\u30e5\u30fc\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30d5\u30a1\u30a4\u30eb\u306f\u5168\u3066ERB\u3067\u306f\u306a\u304f<span style=\"color: #ff0000;\"><strong>Slim\u5f62\u5f0f<\/strong><\/span>\u3067\u4f5c\u6210\u3055\u308c\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u306a\u304a\u3001\u73fe\u6642\u70b9\u3067\u4f5c\u6210\u3055\u308c\u3066\u3057\u307e\u3063\u3066\u3044\u308bERB\u30d5\u30a1\u30a4\u30eb\u3092Slim\u5f62\u5f0f\u306b\u5909\u63db\u3059\u308b\u305f\u3081\u306b\u306f\u4e0b\u8a18\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true \">bundle exec erb2slim \u30c7\u30a3\u30ec\u30af\u30c8\u30ea --delete<\/pre>\n<h2>\u3069\u308c\u3092\u9078\u3079\u3070\u826f\u3044\u306e\uff1f<\/h2>\n<p>\u57fa\u672c\u7684\u306berb\u304c\u826f\u3044\u3067\u3059\u3002\u7406\u7531\u306f\u4ee5\u4e0b\u3067\u3059\u3002<\/p>\n<h3>Rails\u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u8a18\u8ff0\u306a\u306e\u3067\u5b66\u7fd2\u30b3\u30b9\u30c8\u304c\u4f4e\u3044<\/h3>\n<p>Rails\u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u304cerb\u3067\u3059\u3002<\/p>\n<h3>\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3082\u5909\u308f\u3089\u306a\u3044\u3002<\/h3>\n<p>\u6614\u306fslim\u3084haml\u306e\u65b9\u304c\u5f8c\u767a\u306a\u306e\u3067\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u304c\u826f\u3044\u3068\u8a00\u308f\u308c\u3066\u304d\u307e\u3057\u305f\u304c\u3001Rails5.1\u304b\u3089\u51e6\u7406\u7cfb\u304cerubis\u304b\u3089erubi\u306b\u7f6e\u304d\u63db\u308f\u3063\u3066erb\u81ea\u4f53\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3082\u4e0a\u304c\u308a\u305d\u3053\u307e\u3067\u9055\u3044\u306f\u7121\u304f\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<h3>\u8aad\u307f\u3084\u3059\u3044\u3002<\/h3>\n<p>erb\u306f\u901a\u5e38\u306eHTML\u306b\u4f3c\u3066\u3044\u308b\u306e\u3067\u8aad\u307f\u3084\u3059\u3044\u3068\u611f\u3058\u308b\u4eba\u304c\u591a\u3044\u3067\u3059\u3002\u9006\u306bslim\u3084haml\u306f\u7c21\u6f54\u3067\u3059\u304c\u3001\u3069\u3053\u304c\u533a\u5207\u308a\u306b\u306a\u3063\u3066\u3044\u308b\u304b\u5206\u304b\u308a\u3065\u3089\u304f\u53ef\u8aad\u6027\u304c\u4f4e\u3044\u3067\u3059\u3002<\/p>\n<p>\u7279\u306b\u7406\u7531\u304c\u306a\u3044\u306e\u3067\u3042\u308c\u3070erb\u3092\u9078\u3073\u307e\u3057\u3087\u3046\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30a8\u30f3\u30b8\u30f3\u3068\u306f\uff1f \u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3067\u751f\u6210\u3059\u308bHTML\u753b\u9762\u3092\u76f4\u611f\u7684\u306b\u308f\u304b\u308a\u3084\u3059\u3044\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u5f62\u5f0f\u3067\u8a18\u8ff0\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002 ERB Rails\u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30a8\u30f3\u30b8\u30f3\u3067\u3059\u3002ERB\u306e\u8a73\u7d30\u306f\u4e0b\u8a18\u306e\u8a18\u4e8b\u3067\u3082\u89e3 [&hellip;]","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[36],"tags":[],"_links":{"self":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/7562"}],"collection":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7562"}],"version-history":[{"count":9,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/7562\/revisions"}],"predecessor-version":[{"id":20542,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/7562\/revisions\/20542"}],"wp:attachment":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7562"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7562"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7562"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}