webs 0.1.30 → 0.1.31
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/Rakefile +1 -1
- data/lib/helper/tags.rb +29 -5
- data/lib/webs.rb +1 -1
- data/webs.gemspec +1 -1
- metadata +1 -1
data/Rakefile
CHANGED
data/lib/helper/tags.rb
CHANGED
@@ -1,14 +1,34 @@
|
|
1
1
|
module Webs
|
2
2
|
module Helper
|
3
3
|
module Tags
|
4
|
+
# Examples:
|
5
|
+
#
|
6
|
+
# <%= fwml( :blah, :fw_attributes=>{:value=>fwml( :name, :uid=>'xxx') } ) do %>HELLO<% end %>
|
7
|
+
#
|
8
|
+
# Renders:
|
9
|
+
#
|
10
|
+
# <fw:blah>HELLO<fw:fwml_attribute name="value"><fw:name uid="xxx"/></fw:fwml_attribute></fw:blah>
|
11
|
+
|
4
12
|
def fwml tagname, options={}, &block
|
13
|
+
attributes = options.delete( :fw_attributes )
|
5
14
|
# Rails.logger.debug "****** fwml #{tagname} #{options.inspect}"
|
6
15
|
if ['sanitize', 'wizzywig', 'intl'].include?(tagname.to_s)
|
7
|
-
self.send( "fw_#{tagname}", options, &block )
|
16
|
+
tag = self.send( "fw_#{tagname}", options, &block )
|
8
17
|
else
|
9
|
-
|
10
|
-
|
18
|
+
if block
|
19
|
+
tag = render_tag_with_block tagname, options, false, &block
|
20
|
+
else
|
21
|
+
tag = inline_tag( tagname, attributes, options )
|
22
|
+
end
|
11
23
|
end
|
24
|
+
|
25
|
+
if attributes
|
26
|
+
tagidx = tag.length - (tagname.length + 6)
|
27
|
+
attribute_str = attributes.keys.collect{ |k| %[<fw:fwml_attribute name="#{k}">#{attributes[k]}</fw:fwml_attribute>] }.join( "\n" )
|
28
|
+
tag = tag[0..tagidx-1] + attribute_str.html_safe + tag[tagidx..tag.length-1]
|
29
|
+
end
|
30
|
+
|
31
|
+
tag.html_safe
|
12
32
|
end
|
13
33
|
|
14
34
|
private
|
@@ -27,8 +47,12 @@ module Webs
|
|
27
47
|
output.safe_concat("</fw:#{tagname}>")
|
28
48
|
end
|
29
49
|
|
30
|
-
def inline_tag tagname, options
|
31
|
-
|
50
|
+
def inline_tag tagname, attributes = nil, options
|
51
|
+
if attributes
|
52
|
+
"<fw:#{tagname}#{html_options(options)}></fw:#{tagname}>"
|
53
|
+
else
|
54
|
+
"<fw:#{tagname}#{html_options(options)}/>"
|
55
|
+
end
|
32
56
|
end
|
33
57
|
|
34
58
|
def fw_sanitize options={}, &block
|
data/lib/webs.rb
CHANGED
data/webs.gemspec
CHANGED