Skip to content

Commit

Permalink
Had to refactor out the haml_helper because I couldn't get it to load…
Browse files Browse the repository at this point in the history
…. Feel dirty.
  • Loading branch information
suranyami committed Mar 6, 2012
1 parent 1d0e8cb commit 9c40ce1
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 9 deletions.
12 changes: 12 additions & 0 deletions Gemfile.lock
Expand Up @@ -40,9 +40,18 @@ GEM
builder (3.0.0)
diff-lcs (1.1.3)
erubis (2.7.0)
ffi (1.0.11)
formtastic (2.0.2)
rails (~> 3.0)
git (1.2.5)
guard (1.0.0)
ffi (>= 0.5.0)
thor (~> 0.14.6)
guard-rspec (0.6.0)
guard (>= 0.10.0)
guard-spork (0.5.2)
guard (>= 0.10.0)
spork (>= 0.8.4)
hike (1.2.1)
i18n (0.6.0)
jeweler (1.6.4)
Expand Down Expand Up @@ -102,6 +111,7 @@ GEM
rspec_tag_matchers (1.0.0)
nokogiri (>= 1.4.0)
rspec-rails (>= 1.2.6)
spork (0.9.0)
sprockets (2.0.3)
hike (~> 1.2)
rack (~> 1.0)
Expand All @@ -120,6 +130,8 @@ DEPENDENCIES
bundler
formtastic
formtastic-bootstrap!
guard-rspec
guard-spork
jeweler
rcov
rspec
Expand Down
8 changes: 5 additions & 3 deletions lib/formtastic-bootstrap/helpers/buttons_helper.rb
@@ -1,9 +1,7 @@
module FormtasticBootstrap
module Helpers
module ButtonsHelper

include Formtastic::Helpers::ButtonsHelper
include FormtasticBootstrap::Helpers::HamlHelper

def buttons(*args, &block)

Expand All @@ -16,7 +14,11 @@ def buttons(*args, &block)

if block_given?
template.content_tag(:div, html_options) do
contents = capture_block(&block)
contents = if template.respond_to?(:is_haml?) && template.is_haml?
template.capture_haml(&block)
else
template.capture(&block)
end
end
else
args = [:commit] if args.empty?
Expand Down
9 changes: 6 additions & 3 deletions lib/formtastic-bootstrap/helpers/fieldset_wrapper.rb
Expand Up @@ -3,7 +3,6 @@ module Helpers
module FieldsetWrapper

include Formtastic::Helpers::FieldsetWrapper
include FormtasticBootstrap::Helpers::HamlHelper

protected

Expand All @@ -16,14 +15,18 @@ def field_set_and_list_wrapping(*args, &block) #:nodoc:
legend = template.content_tag(:legend, Formtastic::Util.html_safe(legend)) unless legend.blank?

if block_given?
contents = capture_block(&block)
contents = if template.respond_to?(:is_haml?) && template.is_haml?
template.capture_haml(&block)
else
template.capture(&block)
end
end

# Ruby 1.9: String#to_s behavior changed, need to make an explicit join.
contents = contents.join if contents.respond_to?(:join)
fieldset = template.content_tag(:fieldset,
Formtastic::Util.html_safe(legend) << Formtastic::Util.html_safe(contents),
html_options.except(:builder, :parent, :name)
html_options.except(:builder, :parent, :name)
)

fieldset
Expand Down
6 changes: 3 additions & 3 deletions spec/helpers/buttons_helper_spec.rb
Expand Up @@ -133,12 +133,12 @@
end

it 'should render a form with a div containing a input for each button arg' do
output_buffer.should have_tag('form > div.actions > input', :count => 1)
output_buffer.should have_tag('form > div.actions > input.commit', :count => 1)
output_buffer.should have_tag('form > div.form-actions > input', :count => 1)
output_buffer.should have_tag('form > div.form-actions > input.commit', :count => 1)
end

it 'should pass the options down to the div' do
output_buffer.should have_tag('form > div#my-id.actions')
output_buffer.should have_tag('form > div#my-id.form-actions')
end

end
Expand Down

0 comments on commit 9c40ce1

Please sign in to comment.