{"id":4451,"date":"2018-06-19T09:37:00","date_gmt":"2018-06-19T00:37:00","guid":{"rendered":"http:\/\/www.code-magagine.com\/?p=4451"},"modified":"2023-05-27T23:03:02","modified_gmt":"2023-05-27T14:03:02","slug":"%e3%80%90ruby-on-rails%e3%80%91erb%e3%81%ae%e8%a8%98%e8%bf%b0%e3%83%ab%e3%83%bc%e3%83%ab","status":"publish","type":"post","link":"http:\/\/www.code-magagine.com\/?p=4451","title":{"rendered":"\u3010Ruby on Rails\u3011\u30d3\u30e5\u30fc\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\uff08ERB\uff09\u306e\u8a18\u8ff0\u30eb\u30fc\u30eb"},"content":{"rendered":"<h2>ERB\u3068\u306f\uff1f<\/h2>\n<p>\u300cEmbedded RuBy\u300d\u306e\u7565\u3067<span style=\"color: #ff0000;\"><strong>HTML\u306bRuby\u306e\u30b3\u30fc\u30c9\u3092\u57cb\u3081\u8fbc\u307f\u307e\u3059<\/strong><\/span>\u3068\u8a00\u3046\u610f\u5473\u306b\u306a\u308a\u307e\u3059\u3002Rails\u306eMVC\u306e\u30d3\u30e5\u30fc\u90e8\u5206\u306b\u5f53\u305f\u308b<span style=\"color: #ff0000;\"><strong>\u300c\u30d3\u30e5\u30fc\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u300d<\/strong><\/span>\u306e\u3053\u3068\u3067\u3001HTML\u306b\u3088\u304f\u4f3c\u305f\u8a18\u8ff0\u3092\u3057\u307e\u3059\u3002\u30d5\u30a1\u30a4\u30eb\u306e\u62e1\u5f35\u5b50\u306f<span style=\"color: #000000;\">\u300c.html.erb\u300d<\/span>\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<h2>ERB\u306e\u30e1\u30ea\u30c3\u30c8<\/h2>\n<ul>\n<li>\u30d3\u30e5\u30fc\u30d8\u30eb\u30d1\u30fc\u3092\u5229\u7528\u3059\u308b\u3053\u3068\u3067\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u304b\u3089\u53d6\u5f97\u3057\u305f\u5024\u306b\u57fa\u3065\u3044\u3066\u30b7\u30f3\u30d7\u30eb\u306a\u30b3\u30fc\u30c9\u3067\u30d5\u30a9\u30fc\u30e0\u7b49\u306e\u8981\u7d20\u3092\u8a18\u8ff0\u3067\u304d\u308b\u3002<\/li>\n<\/ul>\n<h2>ERB\u306e\u8a18\u8ff0\u30eb\u30fc\u30eb<\/h2>\n<table>\n<tbody>\n<tr>\n<th width=\"150\">\u8a18\u53f7<\/th>\n<th>\u8aac\u660e<\/th>\n<\/tr>\n<tr>\n<td>&lt;% %&gt;<\/td>\n<td>Ruby\u306e\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3068\u3057\u3066\u5b9f\u884c\u3055\u305b\u308b<\/td>\n<\/tr>\n<tr>\n<td>&lt;=% %&gt;<\/td>\n<td>Ruby\u306e\u30b3\u30fc\u30c9\u306e\u5b9f\u884c\u7d50\u679c\uff08\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u3067\u5b9a\u7fa9\u3057\u305f\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u5909\u6570\u7b49\uff09\u3092\u51fa\u529b<\/td>\n<\/tr>\n<tr>\n<td>&lt;%# %&gt;<\/td>\n<td>\u30b3\u30e1\u30f3\u30c8\u69cb\u6587<\/td>\n<\/tr>\n<tr>\n<td>&lt;% if false %&gt;<\/p>\n<p>&lt;% end %&gt;<\/td>\n<td>\u6761\u4ef6\u6587\u3067\u5e38\u306bfalse\u306b\u306a\u308b\u305f\u3081\u5e38\u306b\u7121\u8996\u3055\u308c\u307e\u3059\u3002<\/td>\n<\/tr>\n<tr>\n<td>&lt;=% begin %&gt;<\/p>\n<p>&lt;% end %&gt;<\/td>\n<td>\u8907\u6570\u884c\u30b3\u30e1\u30f3\u30c8\u306b\u4f7f\u3048\u307e\u3059\u3002\uff08\u4e0a\u306e\u6587\u3088\u308a\u3082\u3088\u308a\u30b3\u30e1\u30f3\u30c8\u3068\u8a00\u3046\u3053\u3068\u304c\u308f\u304b\u308a\u3084\u3059\u3044\u3067\u3059\u3002\uff09<\/td>\n<\/tr>\n<tr>\n<td>&lt;!-- --&gt;<\/td>\n<td>HTML\u30b3\u30e1\u30f3\u30c8\u3067\u3059\u3002\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u5074\u306b\u3082\u898b\u3048\u3066\u3057\u307e\u3046\u306e\u3067\u901a\u5e38\u306f\u3042\u307e\u308a\u4f7f\u3046\u3053\u3068\u306f\u306a\u3044\u3067\u3057\u3087\u3046\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>\u5b9f\u88c5\u4f8b<\/h2>\n<h3>&lt;=% %&gt;\uff1aRuby\u306e\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u5074\u306e\u5b9f\u884c\u7d50\u679c\u3092\u51fa\u529b<\/h3>\n<h4>app\/views\/(\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u540d)\/index.html.erb<\/h4>\n<p>\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3067\u5b9a\u7fa9\u3055\u308c\u305f\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u5909\u6570(\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u5909\u6570)\u300c@helloworld\u300d\u3092\u51fa\u529b\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">&lt;%= @helloworld %&gt;<\/pre>\n<h4>app\/controllers\/(\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u540d)_controller.rb<\/h4>\n<p>\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3067\u3001\u300c@helloworld\u300d\u3068\u3044\u3046<span style=\"color: #ff0000;\"><strong>\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u5909\u6570(\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u5909\u6570)<\/strong><\/span>\u3092\u5b9a\u7fa9\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">class TestController &lt; ApplicationController\r\n    def index\r\n        @helloworld = 'Hello World!'\r\n        render template: 'test\/index'\r\n    end\r\nend<\/pre>\n<h4>\u5b9f\u884c\u7d50\u679c<\/h4>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-4446\" src=\"http:\/\/www.code-magagine.com\/wp-content\/uploads\/2018\/06\/rails\u30d3\u30e5\u30fc_\u7d50\u679c\u8868\u793a.png\" alt=\"\" width=\"342\" height=\"99\" srcset=\"http:\/\/www.code-magagine.com\/wp-content\/uploads\/2018\/06\/rails\u30d3\u30e5\u30fc_\u7d50\u679c\u8868\u793a.png 342w, http:\/\/www.code-magagine.com\/wp-content\/uploads\/2018\/06\/rails\u30d3\u30e5\u30fc_\u7d50\u679c\u8868\u793a-300x87.png 300w\" sizes=\"(max-width: 342px) 100vw, 342px\" \/><\/p>\n<h2>slim\u3084haml\u306f\u4f7f\u3046\u3079\u304d\u304b\uff1f<\/h2>\n<p>\u7d50\u8ad6ERB\u3060\u3051\u5b66\u7fd2\u3057\u3066\u304a\u3051\u3070\u5927\u4e08\u592b\u3067\u3059\u3002<\/p>\n<ul>\n<li>Rails\u6a19\u6e96\u306e\u8a18\u8ff0\u30b9\u30bf\u30a4\u30eb\u3060\u304b\u3089\u3002<\/li>\n<li>Web\u6a19\u6e96\u6280\u8853\u3067\u3042\u308bHTML\u306b\u8a18\u8ff0\u304c\u8fd1\u304f\u3066\u5b66\u7fd2\u30b3\u30b9\u30c8\u304c\u4f4e\u3044\u3001\u7406\u89e3\u3057\u3084\u3059\u3044\u3002<\/li>\n<li>Rails\u3082\u9032\u5316\u3092\u91cd\u306d\u3066\u304d\u3066\u3044\u3066\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3082slim\u3084haml\u3068\u5909\u308f\u3089\u306a\u304f\u306a\u3063\u3066\u304d\u3066\u3044\u308b\u3002\uff08\u4ee5\u524d\u306fslim\u3084haml\u306e\u65b9\u304c\u5909\u63db\u306a\u3069\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306f\u9ad8\u304b\u3063\u305f\u3088\u3046\u3067\u3059\u3002\uff09<\/li>\n<\/ul>\n<p>\u305f\u3060\u3001slim\u3084haml\u3092\u4f7f\u3063\u3066\u3044\u308b\u73fe\u5834\u306f\u3044\u307e\u3060\u306b\u591a\u3044\u306e\u3067\u30bd\u30fc\u30b9\u3060\u3051\u306fRails\u30a8\u30f3\u30b8\u30cb\u30a2\u3068\u3057\u3066\u30ad\u30e3\u30ea\u30a2\u3092\u7a4d\u3093\u3067\u3044\u304d\u305f\u3044\u306e\u3067\u3042\u308c\u3070\u3001\u3042\u308b\u7a0b\u5ea6\u5b66\u7fd2\u306f\u5fc5\u8981\u306b\u306a\u308b\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"ERB\u3068\u306f\uff1f \u300cEmbedded RuBy\u300d\u306e\u7565\u3067HTML\u306bRuby\u306e\u30b3\u30fc\u30c9\u3092\u57cb\u3081\u8fbc\u307f\u307e\u3059\u3068\u8a00\u3046\u610f\u5473\u306b\u306a\u308a\u307e\u3059\u3002Rails\u306eMVC\u306e\u30d3\u30e5\u30fc\u90e8\u5206\u306b\u5f53\u305f\u308b\u300c\u30d3\u30e5\u30fc\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u300d\u306e\u3053\u3068\u3067\u3001HTML\u306b\u3088\u304f\u4f3c\u305f\u8a18\u8ff0\u3092\u3057\u307e\u3059\u3002\u30d5\u30a1\u30a4 [&hellip;]","protected":false},"author":1,"featured_media":4265,"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\/4451"}],"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=4451"}],"version-history":[{"count":19,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/4451\/revisions"}],"predecessor-version":[{"id":20554,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/4451\/revisions\/20554"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/media\/4265"}],"wp:attachment":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4451"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4451"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4451"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}