5/31/2007

Markaby:惡趣味的逆襲

有些東西你明知道是錯的,但是還是會去做,只是因為那樣做很爽。

不是說你很邪惡,而只是因為有時候作壞事本身就是一件很有趣的事情。像是蹺課出去打撞球,像是上班偷懶,像是捉弄朋友....等等雖然明知道本身是不對的事情,但是依舊無法抗拒這種快感。第一次看到 Markaby,心中的 OS 是「妖孽呀,這是網頁設計的邪道呀」。但是最近有機會碰到高手寫的 Markaby code ,頓時發覺有點沈溺其中無法自拔(果然是邪道,才會有毒品的快感)。或許這又是一個明知不對,但是又令人忍不住去碰的小誘惑。

敝人小弟在下我曾經寫過HTML?New Template System ?,裡面有提到
Ruby 統一全世界當然是一個美好的夢想,畢竟我是100%原汁的 Ruby 派。但是當你在商業應用上,版面設計通常交給美工,他們只需要會 Dreamweaver 之類的東西
這時候,難道你要教美工 Ruby 程式設計?
所以,除非 Dreamweaver 或是 Frontpage 支援 Ruby @@!,不然大家還是先把 HTML 當成網頁程式設計的最大公約數好了。
因為考慮到美工人員不太會去管程式,程式也沒這個 sense 去碰美工,所以所謂的 template 正道,就是「美工歸美工,程式歸程式」。基本要求是 HTML 版面跟 Rails 程式分開,美工好做事,程式也好修改。

但是 Markaby 就是一個相當詭異的存在,他是一個使用 Ruby Code 來撰寫 html 的方式。他是一個 Rails Plugin ,安裝方式是
 script/plugin install http://code.whytheluckystiff.net/svn/markaby/trunk
rhtml 跟 markaby 是可以兩者並行的,請先將你的 markaby file 都從 .rhtml 改成 .mab 的名字,這樣 rails 就可以知道這是 markaby 的檔案了。

撰寫範例是這樣

h1 'Listing products'

table.editor.classic do
tr do
for column in Product.content_columns
th column.human_name
end
end

for product in @products
tr do
for column in Product.content_columns
td product.send(column.name)
end
td { link_to 'Show', :action => 'show', :id => product }
td { link_to 'Edit', :action => 'edit', :id => product }
td { link_to 'Destroy', { :action => 'destroy', :id => product }, :confirm => 'Are you sure?' }
end
end
end

link_to 'Previous page', { :page => @product_pages.current.previous } if @product_pages.current.previous
link_to 'Next page', { :page => @product_pages.current.next } if @product_pages.current.next

br

link_to 'New product', :action => 'new'
裡面有很多 html tag 跟 Ruby code,Rails helper。裡面看不到煩人的 <% %> 等符號,只有讓人興奮的 Ruby code。

好處呢?

就是一個爽字形容,還有另外一種自己已經成為高手的錯覺。

壞處呢?

你沒辦法用美工改好給你的 HTML code ,你必須要求美工使用 CSS 來做所有排版的工作,不然合作起來也非常累。另外一個壞處是,交接的時候交接的人會很不高興,這是哪門子的版面 code ,要我怎麼看呀。

該不該用呢?

就實際面來說,沒有任何實用價值。但是你也知道,有些東西你明知道是錯的,但是還是會去做,只是因為他很爽。所以夜深人靜的某個夜晚,我依舊偷偷使用 Markaby 來寫我的某個小網頁 :p

22 則留言:

Unknown 提到...

這...這誘惑真大 . . .

匿名 提到...

看起來挺不賴,晚點也來試一下

如果以現今利用CSS和些許的javascript來完成整個頁面的設計來說,那template這邊只要有簡單直覺的寫出html基本結構就足夠。

Haml比較令人讚賞的是他輸出的html是非常整齊的,不會一團亂。

Markaby是完全像是寫ruby code的風格,真的蠻誘人了。

Kiwi 提到...

這就像是好久以前的Perl CGI,不過撰寫一陣子會發現對版面設計一點幫助也沒有。我倒是認為如果有幾個function解決table,div這些使用度很高的HTML便足夠。

匿名 提到...

http://comunidad.terra.es/blogs/ferasinki/default.aspx
http://tiouconnaltli4.blog138.fc2.com/
http://5801.dsd.cx.cc/ Cruisesonly carnival cruise http://c4g.cvc.cx.cc/ Safe hotels in san franscisco http://8479.vbv.cx.cc/ Hotels phoenix az 85054 http://v9v.vbv.cx.cc/ Hotels in jamaica plain ma http://b5l.lkl.cx.cc/ Glenwood springs cottage hotels http://l0o.lkl.cx.cc/ Dorint hotel in hotels columbus http://8674.vbv.cx.cc/ Le ponant cruise ship http://4281.dsd.cx.cc/ Atlantic city nj hotels marriott http://m0m.cvc.cx.cc/ Cruise shuttles london http://528.lkl.cx.cc/ Hotels near greenville new york http://7620.cvc.cx.cc/ Hotels in bartlett il http://m4b.herdersa.cx.cc/ Hotels in greenwood village co http://593.lkl.cx.cc/ Pine mountain club ca hotels http://d1g.lkl.cx.cc/ Cruise holidays of bedford http://a7f.lkl.cx.cc/ Charleston sc smoke free hotels http://g0f.dsd.cx.cc/ Bedix cruise control http://8600.cvc.cx.cc/ Disney mexican riviera cruise http://6032.herdersa.cx.cc/ Cruise for best friends http://5117.herdersa.cx.cc/ Luxury cruises nile http://6511.dsd.cx.cc/ Hotels in chino ca http://j6h.dsd.cx.cc/ Budget hotels in guangzhou http://11848.lkl.cx.cc/ Norwegian spirit cruise shiip http://2627.herdersa.cx.cc/ Is tom cruise http://c1v.herdersa.cx.cc/ Cheap cruise fred olsen http://7861.dsd.cx.cc/ Hotels in montreal village http://m1c.lkl.cx.cc/ Cheapest baja mexico cruises http://f3n.herdersa.cx.cc/ St louis hotels park fly http://w4g.dsd.cx.cc/ Hotels in chicago illinois discount http://4082.herdersa.cx.cc/ Barcelo hotels in juan dolio http://u9e.herdersa.cx.cc/ Cruise scientology interview http://4408.lkl.cx.cc/ Cruise ship sketches http://s2g.dsd.cx.cc/ Beachfront hotels cocoa beach http://g4i.vbv.cx.cc/ Intercontinental hotels group fl http://11780.cvc.cx.cc/ Dog hotels acworth ga http://l3r.cvc.cx.cc/ Carnival cruise med http://r1a.dsd.cx.cc/ Hotels west valley city utah http://11383.lkl.cx.cc/ Aaa aproved hotels in http://y3o.cvc.cx.cc/ Downtown hotels flagstaff az http://p3w.lkl.cx.cc/ Hotels pike lake duluth mn http://e2f.vbv.cx.cc/ Calistoga pool hotels chamber commerce http://x1k.lkl.cx.cc/ Atlanticcity hotels along the boardwalk http://i3v.herdersa.cx.cc/ Corporate suites new hotels http://11719.vbv.cx.cc/ Hotels i-10 east houston area http://i2u.dsd.cx.cc/ United states location nickelodeon hotels http://6399.vbv.cx.cc/ North conway new hampshire hotels http://i7p.cvc.cx.cc/ Jesolo hotels 3 stars http://6278.lkl.cx.cc/ Cruises on royal carribean http://w7j.cvc.cx.cc/ Hotels in new britian ct http://8750.cvc.cx.cc/ Hotels near lake tenkiller oklahoma http://y0b.dsd.cx.cc/ Dc improv nearby hotels http://287.herdersa.cx.cc/ Carnival holiday cruise http://d9o.vbv.cx.cc/ Newburgh ny sightseeing cruises http://3878.lkl.cx.cc/ Teen friendly hotels springfield mo http://1642.herdersa.cx.cc/ Presque isle boat cruise http://g7y.lkl.cx.cc/ Cheap hotels manila philippines

匿名 提到...

http://comunidad.terra.es/blogs/ferasinki/default.aspx
http://tiouconnaltli4.blog138.fc2.com/
http://m1c.lkl.cx.cc/ Cheapest baja mexico cruises http://5577.herdersa.cx.cc/ Ft lauderdale hilton hotels http://9738.lkl.cx.cc/ Hotels ford center oklahoma city http://d.dsd.cx.cc/ Hotels in joshua tree http://y2a.lkl.cx.cc/ Hotels in berlin germany http://u3k.cvc.cx.cc/ Pet friendly wildwood nj hotels http://d6n.vbv.cx.cc/ Arizona resorts and hotels http://8530.cvc.cx.cc/ College booze cruise http://11657.herdersa.cx.cc/ Disney hotels in orlando florida http://m1n.lkl.cx.cc/ Hotels pacific ocean surf panama http://a4e.lkl.cx.cc/ Hotels on south penn okc http://d6p.lkl.cx.cc/ Family christian cruise scotland http://6333.lkl.cx.cc/ Pet friendly hotels in pitts http://r7v.vbv.cx.cc/ Manhattan cruise terminal schedule http://x2t.dsd.cx.cc/ Hotels in roseville ca http://f2p.cvc.cx.cc/ Ncl cooking light cruise http://5513.lkl.cx.cc/ Hotels in ghent wv http://y7y.dsd.cx.cc/ Conde nast reviews cruises http://k9y.herdersa.cx.cc/ Cruise deals uk http://8099.vbv.cx.cc/ Hotels in ko tao thailand http://3702.herdersa.cx.cc/ Hilton hotels niagara falls http://6086.dsd.cx.cc/ Basic wardrobe cruise http://x4m.herdersa.cx.cc/ Hotels in fatima portugal http://q9l.herdersa.cx.cc/ Hotels lake elsinore ca http://1402.herdersa.cx.cc/ Hotels in el colibri sosua http://10479.vbv.cx.cc/ Smiths fern grotto cruise http://9780.cvc.cx.cc/ Hotels and terlingua ct http://e5q.dsd.cx.cc/ Hotels around bethesda md http://q.cvc.cx.cc/ Carnival cruise ship phone http://d7g.cvc.cx.cc/ 1996 cruise role http://11172.herdersa.cx.cc/ Trilogy maui cruises http://g7j.cvc.cx.cc/ Norman wells luxury cruises http://2800.cvc.cx.cc/ Hotels in atlanta georfia http://7671.dsd.cx.cc/ Sauk rapids mn area hotels http://6153.lkl.cx.cc/ 100 night cruises http://5274.vbv.cx.cc/ Hotels in hunnington beach http://6842.herdersa.cx.cc/ Discounted hotels clive ia http://8035.cvc.cx.cc/ Florida hotels treasure island http://j6f.vbv.cx.cc/ Hotels new castle indiana http://d4z.dsd.cx.cc/ Airport hotels and seattle http://o6j.vbv.cx.cc/ Denver aiport shuttle hotels http://o4s.cvc.cx.cc/ Whale watching hawaiian cruises http://3029.vbv.cx.cc/ 5 star hotels naple florida http://6002.herdersa.cx.cc/ Hotels near broomfield co http://1021.dsd.cx.cc/ Gsa travel chicago hotels http://r9m.lkl.cx.cc/ Cruise in nc http://8381.dsd.cx.cc/ Quality assurance inspectors choice hotels http://9502.herdersa.cx.cc/ Star mexico cruise review http://t5f.cvc.cx.cc/ River cruise tour http://o.lkl.cx.cc/ Premium hotels on ca beaches http://o0g.cvc.cx.cc/ Alaska yatch cruises http://4512.herdersa.cx.cc/ New orleans hotels with jacuzzi http://u0b.lkl.cx.cc/ Historic hotels helena montana http://8390.cvc.cx.cc/ Hotels in fort lauderdal flordia http://7035.cvc.cx.cc/ Ms amsterdam cruise ship

匿名 提到...

http://comunidad.terra.es/blogs/ferasinki/default.aspx
http://tiouconnaltli4.blog138.fc2.com/
http://a2b.dsd.cx.cc/ Hotels in beckley wva http://2263.lkl.cx.cc/ Best cruise jokes http://l1a.cvc.cx.cc/ San antonio holiday inn hotels http://9816.dsd.cx.cc/ Cruise control oem http://8171.dsd.cx.cc/ Hotels close to winnipeg airport http://p2d.dsd.cx.cc/ Lake cruises chicago http://6954.vbv.cx.cc/ Discount hotels in kissimmee http://568.lkl.cx.cc/ Airtours cruises ms seawing http://4802.herdersa.cx.cc/ Griffith park california hotels http://5898.lkl.cx.cc/ Electra cruises wedding pictures http://g6c.vbv.cx.cc/ Port chester new york hotels http://6721.dsd.cx.cc/ Cruise ship speed http://5003.lkl.cx.cc/ Cruise critic piraeus greece http://11380.cvc.cx.cc/ Deals hotels baton rouge la http://1679.vbv.cx.cc/ Hotels fort kent maine http://v2l.cvc.cx.cc/ Available hotels in catalina http://u1l.lkl.cx.cc/ Hotels near casco bay lines http://b7i.cvc.cx.cc/ Hotels in sorel canada http://a4l.dsd.cx.cc/ Cheap hotels in mestre italy http://a3g.cvc.cx.cc/ Cheap hotels in rockville maryland http://h5c.lkl.cx.cc/ Humpback whale cruise http://q0f.dsd.cx.cc/ Cheap hotels in buenavista colorado http://547.herdersa.cx.cc/ Cruise dinner fashion http://8924.vbv.cx.cc/ Alaska norwegian pearl cruise http://2069.vbv.cx.cc/ Hotels bandar baru indonesia http://4669.vbv.cx.cc/ Info best alaskan cruises http://3816.dsd.cx.cc/ Cynthia martinez celebrity cruise http://j9j.herdersa.cx.cc/ Cody wyoming hotels motels http://9852.herdersa.cx.cc/ Hollywood beach hotels in miami http://r0k.vbv.cx.cc/ Caribbean cruise reviews http://z9t.lkl.cx.cc/ Holiday inn express hotels kansas http://v8p.dsd.cx.cc/ Croatia hotels with tennis http://j8r.vbv.cx.cc/ Hotels and dayton oh http://8441.dsd.cx.cc/ Jimmy sturr cruise 2010 http://s1h.vbv.cx.cc/ Employee code for choice hotels http://3752.herdersa.cx.cc/ Hotels near meadowbrook pavilion http://f8p.herdersa.cx.cc/ Alaskan cruise stops http://t3z.dsd.cx.cc/ Marriot hotels in provo utah http://f2s.vbv.cx.cc/ Cruise line insurance http://v1u.vbv.cx.cc/ Teen friendly hotels in dorset http://k.vbv.cx.cc/ Discount hotels midway airport http://s9i.vbv.cx.cc/ Hyunday vera cruise used http://5353.lkl.cx.cc/ Hotels near miami cruise terminal http://y8v.vbv.cx.cc/ 5 star hotels sedona arizona http://c1v.dsd.cx.cc/ Cruise to french riviera http://g7x.cvc.cx.cc/ Cruises for under $100.00 http://v2a.dsd.cx.cc/ Tom cruise puppies http://e6c.dsd.cx.cc/ Cruise from india http://5943.lkl.cx.cc/ Family cruise ft myers http://i6k.herdersa.cx.cc/ Erie canal cruise line http://285.cvc.cx.cc/ Eagle grove iowa hotels http://d0r.lkl.cx.cc/ Hotels in modesto california http://11191.dsd.cx.cc/ Hotel riverboat cruises tenn http://n2o.lkl.cx.cc/ Hotels near cedar point sandusky http://u5i.vbv.cx.cc/ Hotels in weymouth dorset uk

匿名 提到...

Allo à tous,

Voulez-vous gagner des prix facilement ?

Le site web Bidou.ca est un un site web amusant qui vous permet de remporter de fantastique prix sans investir enormement!

Venez participer sur: [url=http://bidoubidou.ca/]bidou.ca[/url]

匿名 提到...

Hi guys,

Do you want to watch harry potter and the deathly hallows online? It is not released yet but you can watch it online already!

Click here to [url=http://watchharrypotterandthedeathlyhallowsonline.org/]watch harry potter and the deathly hallows[/url]

匿名 提到...

phbonufwrhaj
Lucky Charms
dmrrvospculb
zpssgaibozgb
Lucky Charms UK
iyjlrytnihjl
jvediqujeaqx
[url=http://www.luckycharms-uk.com]Lucky Charms UK[/url]
vvooeexdpkkr

匿名 提到...

"Nice submit! GA can be my biggest earning. However, it is not a very much.thank you !!!! quite helpful post!"

--------------------------------------------
my website is
http://yogaball.us

Also welcome you!

匿名 提到...

Hello guys,

Would you like to watch the green hornet online? It is not released yet but you can watch it online already!

Click here to [url=http://watch-thegreenhornet-online.com/watch-the-green-hornet-online-free.php]watch the green hornet online free[/url]

匿名 提到...

auto insurance missouri You really make it seem so easy with your presentation but I find this topic to be really something which I think I would never understand. It seems too complicated and very broad for me. I am looking forward for your next post. Erica - car insurance texas

匿名 提到...

Pretty nice post. I just stumbled upon your blog and wanted to say that I have really enjoyed browsing your blog posts. In any case I’ll be subscribing to your feed and I hope you write again soon!

匿名 提到...

Отправь смс

匿名 提到...

Great information! I’ve been looking for something like this for a while now. Thanks!

匿名 提到...

I am really Glad i ran across this site.Added lightyror.thegiive.net to my bookmark!

匿名 提到...

qcyimym xyn qkser anal porno

lyang!

wgkik jkypik xns video handjob

匿名 提到...

Hello. And Bye.

匿名 提到...

mufg lorzd hd porn sbchvf j ma y uvd

匿名 提到...

pzpd hfkte porn hub ozibve i sg a jnh

匿名 提到...

A scarcely any days ago, we analyzed the 2010 originality baseball pitcher sleepers to attend in 2010. Today, we make off a look at the more weighty side of the equation - pretence baseball hitters sleepers.
[url=http://artspacetokyo.com/member/61602/ ]Jack[/url]

匿名 提到...

A only one days ago, we analyzed the 2010 originality baseball pitcher sleepers to attend in 2010. Today, we assess as a look at the more signal side of the equation - pretence baseball hitters sleepers.
[url=http://www.golden-gate-park.com/index.php/forums/member/50496/ ]Jack[/url]