diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/af83/decorator.rb | 12 | ||||
| -rw-r--r-- | lib/af83/enhanced_decorator.rb | 4 |
2 files changed, 14 insertions, 2 deletions
diff --git a/lib/af83/decorator.rb b/lib/af83/decorator.rb index d2e049857..ba9a46cb0 100644 --- a/lib/af83/decorator.rb +++ b/lib/af83/decorator.rb @@ -226,7 +226,7 @@ class AF83::Decorator < ModelDecorator def html_options out = {} options.each do |k, v| - out[k] = v unless k == :content || k == :href || k.to_s =~ /^_/ + out[k] = self.send(k) unless k == :content || k == :href || k.to_s =~ /^_/ end out[:class] = extra_class out.delete(:link_class) @@ -241,7 +241,15 @@ class AF83::Decorator < ModelDecorator yield link return link.bind_to_context(context, @action).to_html end - context.h.link_to content, href, html_options + if type&.to_sym == :button + HTMLElement.new( + :button, + content, + html_options + ).to_html + else + context.h.link_to content, href, html_options + end end end diff --git a/lib/af83/enhanced_decorator.rb b/lib/af83/enhanced_decorator.rb index 4ade0980b..b4e679164 100644 --- a/lib/af83/enhanced_decorator.rb +++ b/lib/af83/enhanced_decorator.rb @@ -16,6 +16,10 @@ module AF83::EnhancedDecorator @_action_links[weight] << link end + def t key + eval "-> (l){ h.t('#{key}') }" + end + def with_condition condition, &block @_condition = condition instance_eval &block |
