推 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