カテゴリー
Wiki内検索
*
最近更新したページ
最新コメント
win32/guitest by stunning seo guys
FrontPage by stunning seo guys
SWIG by awesome things!
Win32/Console by stunning seo guys
FrontPage by awesome things!
Win32SDK_ICM by stunning seo guys
Win32SDK_MM by check it out
Win32SDK_process by stunning seo guys
VisualuRuby by stunning seo guys

わびさび方式

リンク


Rubyist Magazine - qwikWeb の仕組み 【第 1 回】
http://jp.rubyist.net/magazine/?0012-qwikWeb

qwikWeb
http://qwik.jp/qwikWeb.html

Sample


require 'qwik/wabisabi-format-xml'

data = [['りんご',   100, 'すっぱい'],
        ['みかん',    30, 'あまい'],
        ['マンゴー', 200, '甘酸っぱい']]
html = [:html]
head = [:head] << [:title, '果物']
body = [:body]
table = [:table, {:border => 1, :cellpadding => 3}]

table_head = [:tr, {:style => 'background: #ddd;'}]
table_head << [:th, '名前'] << [:th, '値段'] << [:th, '味']
table << table_head
data.each do |elem|
  tr_elem = [:tr]
  tr_elem << [:td, elem[0]]
  tr_elem << [:td, {:align => 'right'}, elem[1]]
  tr_elem << [:td, elem[2]]
  table << tr_elem
end

html << head << (body << table)
puts html.format_xml

  • 表示結果



  • 出力

<html
><head
><title
>果物</title
></head
><body
><table border="1" cellpadding="3"
><tr style="background: #ddd;"
><th
>名前</th
><th
>値段</th
><th
>味</th
></tr
><tr
><td
>りんご</td
><td align="right"
>100</td
><td
>すっぱい</td
></tr
><tr
><td
>みかん</td
><td align="right"
>30</td
><td
>あまい</td
></tr
><tr
><td
>マンゴー</td
><td align="right"
>200</td
><td
>甘酸っぱい</td
></tr
></table
></body
></html
>
2006年04月22日(土) 23:45:31 Modified by aqualung

添付ファイル一覧(全1件)
046fee1a.gif (1.71KB)
Uploaded by aqualung 2006年04月22日(土) 23:31:59



スマートフォン版で見る