{"id":1535,"date":"2006-11-22T14:58:06","date_gmt":"2006-11-22T06:58:06","guid":{"rendered":"http:\/\/ihower.idv.tw\/blog\/archives\/1535"},"modified":"2008-09-29T01:08:35","modified_gmt":"2008-09-28T17:08:35","slug":"rjs-minus-r","status":"publish","type":"post","link":"https:\/\/ihower.tw\/blog\/1535-rjs-minus-r","title":{"rendered":"RJS Minus R (MinusMOR)"},"content":{"rendered":"<p><strong>UPDATE <\/strong>(11\/24): \u9806\u61c9\u5927\u5925\u8981\u6c42\uff0cDan Webb\u91cd\u65b0\u767c\u4e00\u500b <a href=\"http:\/\/www.danwebb.net\/2006\/11\/24\/minusmor-released\">MinusMOR<\/a> \u7248\u672c\uff0c\u4f7f\u7528 .ejs\u00a0\u4f86\u8868\u793a\u00a0JavaScript with embedded Ruby templates\u3002\u9019\u6a23\u5c31\u53ef\u4ee5\u8ddf\u672c\u4f86\u7684 .rjs \u5171\u5b58\u4e86\u3002\u5e0c\u671b\u9019\u500b pure Javascript\u00a0template \u4ee5\u5f8c\u53ef\u4ee5\u52a0\u5165 Rails core \u56c9~<\/p>\n<p>RJS\u662f\u5f88\u68d2\u7684\u73a9\u610f\uff0c\u9019\u6bba\u624b\u7d1a\u7684\u529f\u80fd\u8b93\u4f60\u5bebAJAX response\u8d85\u7c21\u55ae\uff0c\u53ea\u7528Ruby\u5373\u53ef\u3002\u4f46\u662f\u5f88\u660e\u986f\u7684\u5b83\u662f\u500b\u6703\u6f0f\u7684\u62bd\u8c61\u5c64(<a href=\"http:\/\/en.wikipedia.org\/wiki\/Leaky_abstraction\">leaky abstraction<\/a>\uff0c\u4e8b\u5be6\u4e0a\u6839\u64da<a href=\"http:\/\/local.joelonsoftware.com\/mediawiki\/index.php\/The_Joel_on_Software_Translation_Project:%E6%8A%BD%E8%B1%A1%E6%BB%B2%E6%BC%8F%E6%B3%95%E5%89%87\">\u62bd\u8c61\u6ef2\u6f0f\u6cd5\u5247<\/a>\uff0c\u6240\u6709\u91cd\u5927\u7684\u62bd\u8c61\u6a5f\u5236\u5728\u67d0\u7a2e\u7a0b\u5f0f\u4e0a\u90fd\u662f\u6709\u6f0f\u6d1e\u7684)\uff0c\u4e00\u4f46\u958b\u59cb\u6f0f\u800c\u8981\u5bebraw Javascript\u6642\uff0c\u5728RJS\u4e2d\u5c31\u8981\u7528<font face=\"Courier New\">page.call \u4e4b\u985e\u7684<\/font>\uff0c\u4f46\u9019\u5c31\u770b\u8d77\u4f86\u6bd4\u8f03\u919c\u964b\uff0c\u5c24\u5176\u662f\u6709Javascript\u689d\u4ef6\u5f0f\u6216raw Javascript\u5f88\u591a\u7684\u6642\u5019\u3002\u53e6\u5916\u5c31\u662fRJS\u5b8c\u5168\u4f9d\u8cf4Prototype\u8ddfScriptaculous\uff0c\u5982\u679c\u4f60\u8981\u6539\u7528\u5225\u7684Javascript framework\u6642\uff0cRuby\u7248\u7684RJS\u5c31\u4e0d\u592a\u6709\u7528\u4e86\u3002<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.rubyinside.com\/wp-content\/uploads\/2006\/11\/eughnice.jpg\" alt=\"from RubyInside\" title=\"from RubyInside\" \/><\/p>\n<p>\u56e0\u6b64\u5982\u679c\u4f60\u5df2\u7d93\u5f88\u719f Javascript \u8ddf Prototype\uff0c\u6216\u662f\u4f60\u60f3\u6539\u7528\u5225\u7684 Javascript framework\uff0c\u53ef\u80fd\u5c31\u6bd4\u8f03\u60f3\u76f4\u63a5\u7528 Javascript \u4f86\u5beb AJAX response\uff0c\u56e0\u6b64Dan Webb\u63d0\u51fa\u4e00\u500b\u65b0\u9078\u64c7(\u65b0\u5be6\u9a57?)\u00a0\u00a0<a href=\"http:\/\/www.danwebb.net\/2006\/11\/17\/rjs-minus-r\">RJS Minus R<\/a>\u00a0(\u6c92\u6709Ruby\u7684RJS!)\uff0cMinusR \u628a .rjs \u6539\u6210\u5beb\u00a0Javascript (\u7528Erb\u5167\u5d4cRuby code)\uff0c\u4e3b\u8981\u5c31\u662f\u7d66\u4f60\u4e00\u500b js helper \u81ea\u52d5\u547c\u53eb to_json \u4f86\u8f49\u63db Ruby \u8cc7\u6599\u3002<\/p>\n<p>\u8a0e\u8ad6\u4e32\u5728\u722d\u8ad6\u8aaa\u61c9\u8a72\u8981\u7528\u53e6\u5916 extension \u526f\u6a94\u540d\u8868\u793a\u9019\u7a2e pure Javascript\uff0c\u56e0\u70ba\u9019\u500b plugin \u76ee\u524d\u66f4\u6539\u4e86 .rjs \u7684\u5b9a\u7fa9\uff0c\u9020\u6210\u672c\u4f86\u7528ruby\u5beb\u7684 .rjs template \u4e0d\u80fd\u7528\u4e86\u3002\u9019\u90e8\u4efd\u8a72\u600e\u9ebc\u5be6\u4f5c\u89e3\u6c7a\u4f3c\u4e4e\u9084\u6c92\u6709\u5b9a\u8ad6\u3002<\/p>\n<p>DHH\u7684\u56de\u61c9\u8aaa\u7684\u5f88\u597d\uff0c\u9019\u662f\u4e00\u500b\u5f88\u597d\u7684\u5be6\u9a57\u8b93\u6211\u5011\u597d\u597d\u7701\u601dRJS\uff0cRJS\u4e0d\u662f\u842c\u9748\u4e39\uff0c\u5c31\u50cfRails\u7684Active Record\u672c\u8eab\u4e5f\u662f\u500b\u6703\u6d29\u6f0fSQL\u62bd\u8c61\u5c64\uff0c\u91cd\u9ede\u662f\u5982\u4f55\u8b9380%\u7684\u5de5\u4f5c\u53ef\u4ee5\u8d85\u7c21\u55ae\u9054\u6210\uff0cand \u53e6\u5916\u768420%\u6709\u5f48\u6027\u624b\u52d5\u4f86\u8b8a\u82b1\u6a23\u3002<\/p>\n<p>\u53e6\u4e00\u7bc7\u4ecb\u7d39\u6587: <a href=\"http:\/\/www.lukeredpath.co.uk\/2006\/11\/17\/rjs-templates-without-the-r\">RJS templates without the R!<\/a><\/p>\n<p>\u8a3b: \u76ee\u524d\u7684stable Rails\u7248\u672c\u4e0d\u884c\u8dd1\u9019\u500b plugin\uff0c\u5fc5\u9808\u88dd<a href=\"http:\/\/wiki.rubyonrails.org\/rails\/pages\/EdgeRails\">EdgeRails<\/a>(\u958b\u767c\u4e2d\u7684Rails\u7248\u672c)\uff0c\u8acb\u57f7\u884c rake rails:freeze:edge \u5b89\u88dd (\u8981\u6709subversion)\u3002\u53e6\u5916 EdgeRails \u53ea\u7528\u65bc\u8a72 rails application\uff0c\u800c\u4e0d\u662f\u6574\u500b\u5347\u7d1a\u7cfb\u7d71 library \u7684Rails\u7248\u672c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>UPDATE (11\/24): \u9806\u61c9\u5927\u5925\u8981\u6c42\uff0cDan Webb\u91cd\u65b0\u767c\u4e00\u500b MinusMOR \u7248\u672c\uff0c\u4f7f\u7528 .ej &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/ihower.tw\/blog\/1535-rjs-minus-r\" class=\"more-link\">\u95b1\u8b80\u5168\u6587<span class=\"screen-reader-text\">\u3008RJS Minus R (MinusMOR)\u3009<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[33,5,53],"tags":[],"class_list":["post-1535","post","type-post","status-publish","format-standard","hentry","category-javascript","category-programming","category-rails","entry"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p1q6tG-oL","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/ihower.tw\/blog\/wp-json\/wp\/v2\/posts\/1535","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ihower.tw\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ihower.tw\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ihower.tw\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ihower.tw\/blog\/wp-json\/wp\/v2\/comments?post=1535"}],"version-history":[{"count":0,"href":"https:\/\/ihower.tw\/blog\/wp-json\/wp\/v2\/posts\/1535\/revisions"}],"wp:attachment":[{"href":"https:\/\/ihower.tw\/blog\/wp-json\/wp\/v2\/media?parent=1535"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ihower.tw\/blog\/wp-json\/wp\/v2\/categories?post=1535"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ihower.tw\/blog\/wp-json\/wp\/v2\/tags?post=1535"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}