我可以使用什么gem来生成脱机使用的HTML文件? [英] What gem can I use to generate a HTML file for offline use?
本文介绍了我可以使用什么gem来生成脱机使用的HTML文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我必须创建一个报告,为了做一些着色和表格,我决定使用HTML。有没有我可以用来做这件事的宝石?我希望避免自己写标签。 ://markaby.rubyforge.org/相对= nofollow noreferrer> Markaby的肩头它可以让你通过一个Ruby DSL生成HTML
这一个例子官方文档:
require'markaby'
mab = Markaby :: Builder.new
mab.html do
head {titleBoats.com}
body do
h1Boats.com有很多优惠
ul do
li $ 49独木舟
礼 39 $的木筏
李 $ 29一个巨大的引导漂浮和可容纳5人的
结束
结束
结束
puts mab.to_s
或者,您可以查看许多可用的模板引擎之一。例如:
- RDiscount / Markdown (编辑时用于堆栈溢出的标记)
- Haml
- RedCloth (请参阅Jonas answer举例来说)
I have to create a report, and in order to do some colouring and tables, I decided on HTML. Is there any gem I could use to do this? I'd like to avoid having to write the tags myself.
解决方案
You can take a look at Markaby which lets you generate HTML through a Ruby DSL.
An example from the official docs:
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
Alternatively you can look into one of the many template engines available. For example:
- RDiscount/Markdown (The markup used in Stack Overflow when editing)
- Haml
- RedCloth (See Jonas answer for an example)
这篇关于我可以使用什么gem来生成脱机使用的HTML文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文