html_gen 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/VERSION +1 -1
- data/html_gen.gemspec +8 -8
- data/lib/html_gen_element.rb +15 -3
- data/lib/html_gen_text_ele.rb +1 -1
- metadata +4 -6
data/Gemfile.lock
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.5
|
data/html_gen.gemspec
CHANGED
@@ -4,14 +4,14 @@
|
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
|
-
s.name =
|
8
|
-
s.version = "0.0.
|
7
|
+
s.name = "html_gen"
|
8
|
+
s.version = "0.0.5"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Kasper Johansen"]
|
12
|
-
s.date =
|
13
|
-
s.description =
|
14
|
-
s.email =
|
12
|
+
s.date = "2012-09-13"
|
13
|
+
s.description = "A small framework for generating HTML."
|
14
|
+
s.email = "k@spernj.org"
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"LICENSE.txt",
|
17
17
|
"README.rdoc"
|
@@ -34,11 +34,11 @@ Gem::Specification.new do |s|
|
|
34
34
|
"spec/html_gen_spec.rb",
|
35
35
|
"spec/spec_helper.rb"
|
36
36
|
]
|
37
|
-
s.homepage =
|
37
|
+
s.homepage = "http://github.com/kaspernj/html_gen"
|
38
38
|
s.licenses = ["MIT"]
|
39
39
|
s.require_paths = ["lib"]
|
40
|
-
s.rubygems_version =
|
41
|
-
s.summary =
|
40
|
+
s.rubygems_version = "1.8.24"
|
41
|
+
s.summary = "A small framework for generating HTML."
|
42
42
|
|
43
43
|
if s.respond_to? :specification_version then
|
44
44
|
s.specification_version = 3
|
data/lib/html_gen_element.rb
CHANGED
@@ -10,6 +10,8 @@
|
|
10
10
|
#
|
11
11
|
# ele.html #=> "<a href=\"http://www.youtube.com\" style=\"font-weight: bold;\" class=\"custom_link\">\n\t<b>\n\t\tTitle of link\n\t</b>\n</a>\n"
|
12
12
|
class Html_gen::Element
|
13
|
+
FORBIDDEN_SHORT = ["script"]
|
14
|
+
|
13
15
|
#Attributes hash which will be used to generate attributes-elements.
|
14
16
|
#===Example
|
15
17
|
# element.attr[:href] = "http://www.youtube.com"
|
@@ -86,6 +88,8 @@ class Html_gen::Element
|
|
86
88
|
return ele
|
87
89
|
end
|
88
90
|
|
91
|
+
alias add add_ele
|
92
|
+
|
89
93
|
#Add a text-element to the element.
|
90
94
|
def add_str(str)
|
91
95
|
ele = Html_gen::Text_ele.new(:str => str, :inden => @inden, :nl => @nl)
|
@@ -157,14 +161,22 @@ class Html_gen::Element
|
|
157
161
|
str << " #{key}=\"#{Html_gen.escape_html(val)}\""
|
158
162
|
end
|
159
163
|
|
160
|
-
|
164
|
+
forbidden_short = FORBIDDEN_SHORT.include?(@name.to_s)
|
165
|
+
skip_pretty = false
|
166
|
+
|
167
|
+
if @eles.empty? and @str.empty? and @str_html.empty? and !forbidden_short
|
161
168
|
#If no sub-string, sub-HTML or sub-elements are given, we should end the HTML with " />".
|
162
169
|
str << " />"
|
163
170
|
str << @nl if pretty
|
164
171
|
else
|
165
172
|
#Write end-of-element and then all sub-elements.
|
166
173
|
str << ">"
|
167
|
-
|
174
|
+
|
175
|
+
if @eles.empty? and @str.empty? and @str_html.empty? and forbidden_short
|
176
|
+
skip_pretty = true
|
177
|
+
end
|
178
|
+
|
179
|
+
str << @nl if pretty and !skip_pretty
|
168
180
|
|
169
181
|
if !@str.empty?
|
170
182
|
str << @inden * (level + 1) if pretty
|
@@ -182,7 +194,7 @@ class Html_gen::Element
|
|
182
194
|
str << subele.html(pass_args)
|
183
195
|
end
|
184
196
|
|
185
|
-
str << @inden * level if pretty and level > 0
|
197
|
+
str << @inden * level if pretty and level > 0 and !skip_pretty
|
186
198
|
str << "</#{@name}>"
|
187
199
|
str << @nl if pretty
|
188
200
|
end
|
data/lib/html_gen_text_ele.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: html_gen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.5
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Kasper Johansen
|
@@ -10,8 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2012-
|
14
|
-
default_executable:
|
13
|
+
date: 2012-09-13 00:00:00 Z
|
15
14
|
dependencies:
|
16
15
|
- !ruby/object:Gem::Dependency
|
17
16
|
name: rspec
|
@@ -83,7 +82,6 @@ files:
|
|
83
82
|
- spec/html_gen_parser_spec.rb
|
84
83
|
- spec/html_gen_spec.rb
|
85
84
|
- spec/spec_helper.rb
|
86
|
-
has_rdoc: true
|
87
85
|
homepage: http://github.com/kaspernj/html_gen
|
88
86
|
licenses:
|
89
87
|
- MIT
|
@@ -97,7 +95,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
97
95
|
requirements:
|
98
96
|
- - ">="
|
99
97
|
- !ruby/object:Gem::Version
|
100
|
-
hash:
|
98
|
+
hash: -1265875924025815085
|
101
99
|
segments:
|
102
100
|
- 0
|
103
101
|
version: "0"
|
@@ -110,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
110
108
|
requirements: []
|
111
109
|
|
112
110
|
rubyforge_project:
|
113
|
-
rubygems_version: 1.
|
111
|
+
rubygems_version: 1.8.24
|
114
112
|
signing_key:
|
115
113
|
specification_version: 3
|
116
114
|
summary: A small framework for generating HTML.
|