From 40b24799aff1742604339781980e5fea637be4c0 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Sun, 25 Nov 2012 22:15:34 -0500 Subject: [PATCH] some fixes --- lib/semantic_rails_view_helpers/attributes_builder.rb | 6 +++++- lib/semantic_rails_view_helpers/view_helpers.rb | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/semantic_rails_view_helpers/attributes_builder.rb b/lib/semantic_rails_view_helpers/attributes_builder.rb index b7dccd2..dc3a067 100644 --- a/lib/semantic_rails_view_helpers/attributes_builder.rb +++ b/lib/semantic_rails_view_helpers/attributes_builder.rb @@ -16,11 +16,15 @@ module SemanticRailsViewHelpers @context.capture(self, &@block) end - def field(field, options = {}) + def field(field, options = {}, &block) if options[:value] raw_value = options[:value] else raw_value = @object.send(field) + + if block + raw_value = block.call(raw_value) + end end value = raw_value diff --git a/lib/semantic_rails_view_helpers/view_helpers.rb b/lib/semantic_rails_view_helpers/view_helpers.rb index c887fc4..7c68702 100644 --- a/lib/semantic_rails_view_helpers/view_helpers.rb +++ b/lib/semantic_rails_view_helpers/view_helpers.rb @@ -41,8 +41,8 @@ module SemanticRailsViewHelpers link_to label, polymorphic_url(route, :action => action), options.merge("data-action" => target_action) end - def li_for(object, &block) - content_tag(:li, capture(&block), 'data-id' => object.id) + def li_for(object, options = {}, &block) + content_tag(:li, capture(&block), options.merge('data-id' => object.id)) end end end