ahc 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ahcx_template_handler.rb +12 -1
- metadata +2 -2
@@ -3,6 +3,10 @@ require 'htmlcompressor'
|
|
3
3
|
|
4
4
|
class AhcxTemplateHandler
|
5
5
|
|
6
|
+
ESCAPED_SYMBOLS = {
|
7
|
+
'&' => '(|escapeahx|and|)'
|
8
|
+
}
|
9
|
+
|
6
10
|
def self.call(template)
|
7
11
|
erb = ActionView::Template.registered_template_handler(:erb)
|
8
12
|
source = erb.call(template)
|
@@ -28,11 +32,18 @@ class AhcxTemplateHandler
|
|
28
32
|
params[child_node_attr] = attr_value
|
29
33
|
end
|
30
34
|
end
|
31
|
-
Ahc.render(tag, params)
|
35
|
+
html = Ahc.render(tag, params)
|
36
|
+
ESCAPED_SYMBOLS.each do |sym, escaped_sym|
|
37
|
+
html.gsub!(escaped_sym, sym)
|
38
|
+
end
|
39
|
+
html
|
32
40
|
end
|
33
41
|
|
34
42
|
def self.render(xml)
|
35
43
|
ahcx_source = "<document>#{xml}</document>"
|
44
|
+
ESCAPED_SYMBOLS.each do |sym, escaped_sym|
|
45
|
+
ahcx_source.gsub!(sym, escaped_sym)
|
46
|
+
end
|
36
47
|
ahcx = Nokogiri.parse(ahcx_source)
|
37
48
|
content = ''
|
38
49
|
ahcx.children.first.children.each do |node|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ahc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -134,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
134
|
version: '0'
|
135
135
|
requirements: []
|
136
136
|
rubyforge_project:
|
137
|
-
rubygems_version: 1.8.
|
137
|
+
rubygems_version: 1.8.23
|
138
138
|
signing_key:
|
139
139
|
specification_version: 3
|
140
140
|
summary: Gem for using ahc components in rails application
|