undies 3.0.0.rc.2 → 3.0.0.rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile.lock +1 -1
- data/lib/undies/api.rb +4 -6
- data/lib/undies/element.rb +7 -8
- data/lib/undies/element_node.rb +2 -2
- data/lib/undies/root_node.rb +1 -1
- data/lib/undies/template.rb +11 -8
- data/lib/undies/version.rb +1 -1
- data/test/template_test.rb +4 -3
- metadata +4 -4
data/Gemfile.lock
CHANGED
data/lib/undies/api.rb
CHANGED
@@ -50,19 +50,19 @@ module Undies
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def open_element(name, *args)
|
53
|
-
|
53
|
+
Element::Open.new(name, *args)
|
54
54
|
end
|
55
55
|
alias_method :open_tag, :open_element
|
56
56
|
alias_method :element, :open_element
|
57
57
|
alias_method :tag, :open_element
|
58
58
|
|
59
59
|
def closed_element(name, *args)
|
60
|
-
|
60
|
+
Element::Closed.new(name, *args)
|
61
61
|
end
|
62
62
|
alias_method :closed_tag, :closed_element
|
63
63
|
|
64
64
|
SELF_CLOSING_TAGS.each do |tag|
|
65
|
-
define_method(tag){ |*args| closed_element(tag, *args
|
65
|
+
define_method(tag){ |*args| closed_element(tag, *args) }
|
66
66
|
end
|
67
67
|
|
68
68
|
OPEN_TAGS.each do |tag|
|
@@ -89,9 +89,7 @@ module Undies
|
|
89
89
|
def __closed_element(name, *args)
|
90
90
|
@_undies_io.
|
91
91
|
current.
|
92
|
-
element_node(ElementNode.new(
|
93
|
-
@_undies_io, Element::Closed.new(name, *args)
|
94
|
-
)).
|
92
|
+
element_node(ElementNode.new(@_undies_io, Element::Closed.new(name, *args))).
|
95
93
|
element
|
96
94
|
end
|
97
95
|
alias_method :__closed_tag, :__closed_element
|
data/lib/undies/element.rb
CHANGED
@@ -44,7 +44,6 @@ module Undies
|
|
44
44
|
|
45
45
|
module CSSProxy
|
46
46
|
|
47
|
-
# CSS proxy methods ============================================
|
48
47
|
ID_METH_REGEX = /^([^_].+)!$/
|
49
48
|
CLASS_METH_REGEX = /^([^_].+)$/
|
50
49
|
|
@@ -67,7 +66,6 @@ module Undies
|
|
67
66
|
super
|
68
67
|
end
|
69
68
|
end
|
70
|
-
# ==============================================================
|
71
69
|
|
72
70
|
end
|
73
71
|
|
@@ -86,14 +84,15 @@ module Undies
|
|
86
84
|
|
87
85
|
class Raw < ::String
|
88
86
|
|
89
|
-
# A Raw string is one that is impervious to String#gsub
|
90
|
-
# when `to_s` is called.
|
87
|
+
# A Raw string is one that is impervious to String#gsub
|
88
|
+
# and returns itself when `to_s` is called. Used to circumvent
|
89
|
+
# the default html escaping of markup
|
91
90
|
|
92
|
-
def gsub(*args
|
91
|
+
def gsub(*args)
|
93
92
|
self
|
94
93
|
end
|
95
94
|
|
96
|
-
def gsub!(*args
|
95
|
+
def gsub!(*args)
|
97
96
|
nil
|
98
97
|
end
|
99
98
|
|
@@ -135,7 +134,7 @@ module Undies
|
|
135
134
|
end
|
136
135
|
|
137
136
|
def to_s
|
138
|
-
"#{__start_tag}#{__content}#{__end_tag}"
|
137
|
+
Raw.new("#{__start_tag}#{__content}#{__end_tag}")
|
139
138
|
end
|
140
139
|
|
141
140
|
def ==(other)
|
@@ -193,7 +192,7 @@ module Undies
|
|
193
192
|
def __end_tag; ''; end
|
194
193
|
|
195
194
|
def to_s
|
196
|
-
"#{__start_tag}"
|
195
|
+
Raw.new("#{__start_tag}")
|
197
196
|
end
|
198
197
|
|
199
198
|
def ==(other)
|
data/lib/undies/element_node.rb
CHANGED
data/lib/undies/root_node.rb
CHANGED
data/lib/undies/template.rb
CHANGED
@@ -46,18 +46,21 @@ module Undies
|
|
46
46
|
self.instance_variable_set("@#{k}", v)
|
47
47
|
end
|
48
48
|
|
49
|
-
# setup a source stack with the given source
|
50
|
-
source = args.last.kind_of?(Source) ? args.pop : Source.new(Proc.new {})
|
51
|
-
@_undies_source_stack = SourceStack.new(source)
|
52
|
-
|
53
49
|
# push a root node onto the IO
|
54
50
|
@_undies_io.push!(RootNode.new(@_undies_io)) if @_undies_io.empty?
|
55
51
|
|
56
|
-
#
|
57
|
-
|
52
|
+
# if given some source, build it
|
53
|
+
if args.last.kind_of?(Source)
|
54
|
+
# setup a source stack with the given source
|
55
|
+
@_undies_source_stack = SourceStack.new(args.pop)
|
56
|
+
|
57
|
+
# yield to recursivley render the source stack
|
58
|
+
__yield
|
59
|
+
|
60
|
+
# flush any elements that need to be built
|
61
|
+
__flush
|
62
|
+
end
|
58
63
|
|
59
|
-
# flush any elements that need to be built
|
60
|
-
__flush
|
61
64
|
end
|
62
65
|
|
63
66
|
end
|
data/lib/undies/version.rb
CHANGED
data/test/template_test.rb
CHANGED
@@ -96,7 +96,8 @@ class Undies::Template
|
|
96
96
|
desc "using the captured element api methods"
|
97
97
|
|
98
98
|
should "capture `element` output as Raw output" do
|
99
|
-
assert_kind_of Undies::
|
99
|
+
assert_kind_of Undies::Element::Closed, subject.closed_element(:br)
|
100
|
+
assert_kind_of Undies::Raw, subject.closed_element(:br).to_s
|
100
101
|
end
|
101
102
|
|
102
103
|
should "capture `element` output correctly" do
|
@@ -110,9 +111,9 @@ class Undies::Template
|
|
110
111
|
should "capture and escape data approptiately" do
|
111
112
|
elem = subject.open_element(:span, *[
|
112
113
|
"stuff & <em>more stuff</em>",
|
113
|
-
subject.strong(subject.
|
114
|
+
subject.strong(subject.img.awesome, ' (here)')
|
114
115
|
])
|
115
|
-
assert_equal "<span>stuff & <em>more stuff</em><strong><
|
116
|
+
assert_equal "<span>stuff & <em>more stuff</em><strong><img class=\"awesome\" /> (here)</strong></span>", elem.to_s
|
116
117
|
end
|
117
118
|
|
118
119
|
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: undies
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15424115
|
5
5
|
prerelease: 6
|
6
6
|
segments:
|
7
7
|
- 3
|
8
8
|
- 0
|
9
9
|
- 0
|
10
10
|
- rc
|
11
|
-
-
|
12
|
-
version: 3.0.0.rc.
|
11
|
+
- 3
|
12
|
+
version: 3.0.0.rc.3
|
13
13
|
platform: ruby
|
14
14
|
authors:
|
15
15
|
- Kelly Redding
|
@@ -17,7 +17,7 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2012-04-
|
20
|
+
date: 2012-04-21 00:00:00 Z
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
23
23
|
type: :development
|