作者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
1F:→ poga:看来会是LISP统治全世界  ̄▽ ̄ 09/18 16:48
2F:→ Schelfaniel:Lisp 本身问题很多的, 不过一些概念还可以参考说 @_@ 09/19 05:10