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.
Files changed (5) hide show
  1. data/Rakefile +1 -1
  2. data/lib/helper/tags.rb +29 -5
  3. data/lib/webs.rb +1 -1
  4. data/webs.gemspec +1 -1
  5. metadata +1 -1
data/Rakefile CHANGED
@@ -3,7 +3,7 @@ require 'rubygems'
3
3
  require 'rake'
4
4
  require 'echoe'
5
5
 
6
- Echoe.new('webs', '0.1.30') do |p|
6
+ Echoe.new('webs', '0.1.31') do |p|
7
7
  p.description = "Reusable webs stuff."
8
8
  p.url = "https://colczak@github.com/websdev/websgem.git"
9
9
  p.author = "Chuck Olczak"
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
- return inline_tag( tagname, options ) unless block
10
- render_tag_with_block tagname, options, false, &block
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
- "<fw:#{tagname}#{html_options(options)}/>"
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
@@ -7,7 +7,7 @@ require dir + 'helper/params'
7
7
  require dir + 'helper/tags'
8
8
 
9
9
  module Webs
10
- VERSION = '0.1.30'.freeze
10
+ VERSION = '0.1.31'.freeze
11
11
 
12
12
  def self.app_title
13
13
  APP_NAME.titleize
data/webs.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{webs}
5
- s.version = "0.1.30"
5
+ s.version = "0.1.31"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Chuck Olczak"]
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: webs
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.30
5
+ version: 0.1.31
6
6
  platform: ruby
7
7
  authors:
8
8
  - Chuck Olczak