module HtmlUtils
Constants
- VERSION
Public Class Methods
importHTML(urls)
click to toggle source
Generates HTML-loading code. Good for polymer-using apps.
# File lib/htmlutils/macro.rb, line 21 def self.importHTML(urls) str = "" urls.each do |url| str << %{<link rel="import" href="#{url}">\n} end str end
keywords(words)
click to toggle source
Allows easily adding keywords
# File lib/htmlutils/macro.rb, line 52 def self.keywords(words) str = "" words.each do |word| str << "#{word}," end %{<meta name="keywords" contents="#{str[0..-2]}">} end
loadScripts(urls, type="text/javascript")
click to toggle source
Generates script-loading code
# File lib/htmlutils/macro.rb, line 3 def self.loadScripts(urls, type="text/javascript") str = "" urls.each do |url| str << %{<script type="#{type}" src="#{url}"></script>\n} end str end
loadStyles(urls, type="text/css")
click to toggle source
Generates style-loading code
# File lib/htmlutils/macro.rb, line 12 def self.loadStyles(urls, type="text/css") str = "" urls.each do |url| str << %{<link type="#{type}" rel="stylesheet" href="#{url}">\n} end str end
makeVTable(data, mainAttr="", trhAttr="", thAttr="", trAttr="", tdAttr="")
click to toggle source
Generates vertical table
# File lib/htmlutils/macro.rb, line 30 def self.makeVTable(data, mainAttr="", trhAttr="", thAttr="", trAttr="", tdAttr="") str = "" str << "<table #{mainAttr}>\n" str << " <tr #{trhAttr}>\n" data.each do |d| str << %{ <th #{thAttr}>#{d[0]}</th>\n} end str << " </tr>\n" data.each do |d| str << " <tr #{trAttr}>\n" d[1..-1].each do |d1| str << " <td #{tdAttr}>#{d1}</td>\n" end str << " </tr>\n" end str << "</table>\n" end
utf8()
click to toggle source
Shortcut for string below
# File lib/htmlutils/macro.rb, line 61 def self.utf8 %{<meta charset="UTF-8">} end