精華區beta Ruby 關於我們 聯絡資訊
本文出自此 http://lightyror.blogspot.com/2006/09/htmlnew-template-system.html 現行 Scripting Language 不管PHP,ASP,ruby大多是採用 <td width="100%"> <b> <%= link_to '請按此' , :action => 'index' %> </b></td> 類似這樣的形式 也就是 HTML 為主,並且在裡面嵌入 scripting language code Rails erb 也是這樣的作法 不過Ruby 愛好者有一種不知道是好還是壞的想法 VIVA ,Ruby 統一全世界 Javascript 用 RJS 併吞掉 SQL 用 ActiveRecord and Migrate 併吞掉 Web Service 用 Action Web Service Mail 用 Action Mailer 甚至Web Server 都有 Ruby 版本( Webricks 還有 Mongrel ) 這些我都相當的贊成 因為 Javascript 跟 SQL 的混亂已經嚴重影響到程式設計師 今天卻發現 HAML and MarkBy 可以讓 HTML 也危在旦夕(笑) HAML 就是原本的RHTML <small><%= item.body %></small> 變成 %small= item.body 而MarkBy更是厲害 require 'markaby' mab = Markaby::Builder.new mab.html do head { title "Boats.com" } body do h1 "Boats.com has great deals" ul do li "$49 for a canoe" li "$39 for a raft" li "$29 for a huge boot that floats and can fit 5 people" end end end puts mab.to_s 如此用 Ruby 寫出 HTML @@! 對岸這對於這方面的態度是將這些東西,歸類在近乎奇淫技巧 上面 我的感覺是這樣 還記得 OSDC 2006 in TW上面,Ingy 在講到Wiki語法混亂的問題時(只憑記憶,有錯請見諒) 有人說 Wiki 語法太多太亂,需要 Standard 統一 ,但是依我所見,其實現在早就有 WIKI Standard 了,那就是 HTML Ruby 統一全世界當然是一個美好的夢想 畢竟我是100%原汁的 Ruby 派 但是當你在商業應用上 版面設計通常交給美工 他們只需要會 Dreamweaver 之類的東西 這時候,難道你要教美工 Ruby 程式設計? 所以,除非 Dreamweaver 或是 Frontpage 支援 Ruby @@! 不然大家還是先把 HTML 當成網頁程式設計的最大公約數好了 -- lighty RoR 是一個介紹 lighttpd , SQLite , Ruby and Rails 的 Blog http://lightyror.blogspot.com/ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.218.90.242 ※ 編輯: giive 來自: 61.218.90.242 (09/18 14:17)
godfat:寫個 parser 將 HTML 轉成 Ruby code 吧 :p 09/18 14:25
> -------------------------------------------------------------------------- < 作者: Schelfaniel (Test) 看板: Ruby 標題: Re: [心得] HTML?New Template System ? 時間: Mon Sep 18 14:23:00 2006 ※ 引述《giive (lala)》之銘言: : require 'markaby' : mab = Markaby::Builder.new : mab.html do : head { title "Boats.com" } : body do : h1 "Boats.com has great deals" : ul do : li "$49 for a canoe" : li "$39 for a raft" : li "$29 for a huge boot that floats and can fit 5 people" : end : end : end 其實這個和 Common Lisp 的 Uncommon Web 架構類似說 @_@ 如以下的 @_@ (defmethod render ((hello-world hello-world)) (<:as-is "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \ "http://www.w3.org/TR/xhtml1/DTD/transitional.dtd\">" #\Newline) (<:html (<:head (<:meta :http-equiv "Content-Type" :content "text/html; charset=utf-8;") (<:title (<:as-html "hi")) (<:link :rel "stylesheet" :href "sheet.css" :type "text/css") (<:link :rel "stylesheet" :href "sheet2.css" :type "text/css") (<:script ;; most browsers (firefox, safari and ie at least) really, ;; really, really don't like empty script tags. The "" forces ;; yaclml to generate a seperate closing tag. :type "text/javascript" :src "dojo.js" "") (<:script :type "text/javascript" (<:as-is (js:js* '(dojo.require "dojo.ev ent.*")))) (<:script :type "text/javascript" (<:as-is "var foo = 3;"))) (<:body (<:as-html "hello world")))) -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.220.34.34
poga:看來會是LISP統治全世界  ̄▽ ̄ 09/18 16:48
Schelfaniel:Lisp 本身問題很多的, 不過一些概念還可以參考說 @_@ 09/19 05:10
> -------------------------------------------------------------------------- < 作者: qrtt1 (愚者) 看板: Ruby 標題: Re: [心得] HTML?New Template System ? 時間: Wed Sep 20 17:19:46 2006 自己用過asp 2.0、php、cakephp、 jsp/servlet((jstl)/struts/spring mvc/tapesrty/wicket) 發現最喜歡的"嵌值"模式大概還是tapesrty/wicket一派的方式:P 這其實不算是樣版系統,而是在原html等marked language之下,加入合乎語法 但不是真正存在的tag或屬性。再由framework本身去filter。 (優點是幾乎所有所見即所得的html editor都可以相處愉快) ============================================================================ (http://wicket.sourceforge.net/ExampleHelloWorld.html) <html> <body> <span wicket:id="message">Message goes here</span> </body> </html> ============================================================================ 程式只要辨示wicket:id 再替換掉Message goes here (這是個偽值) 呵,當然每套framework有他的主張, 只是突然想到想介紹一下還有這一種style ※ 引述《giive (lala)》之銘言: -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 163.26.34.20 ※ 編輯: qrtt1 來自: 163.26.34.20 (09/20 17:20) ※ 編輯: qrtt1 來自: 163.26.34.20 (09/20 17:24)
godfat:推 09/21 17:45