Module: UiHelper
- Defined in:
- app/helpers/ui_helper.rb
Instance Method Summary collapse
- #ui(*args, &block) ⇒ Object
- #ui_capture(*args, &block) ⇒ Object
- #ui_group(xrb) ⇒ Object
- #ui_image_block(xrb) ⇒ Object
- #ui_link(xrb) ⇒ Object
-
#ui_output ⇒ Object
helper.
Instance Method Details
#ui(*args, &block) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'app/helpers/ui_helper.rb', line 3 def ui(*args, &block) component = [] if args.length == 1 && args.first.is_a?(Hash) && args.first.length == 1 component << args.first.keys.first else while args.first.is_a? Symbol component << args.shift end end component = "ui_#{component.join '_'}" xrb = ui_capture(*args, &block) @components << xrb if @components self.send(component, xrb) end |
#ui_capture(*args, &block) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'app/helpers/ui_helper.rb', line 60 def ui_capture(*args, &block) xrb = ::XRB::Element.new xrb.attributes = args. if block @components, old_components = [], @components xrb.inner_content = capture(&block) xrb.components = @components @components = old_components else xrb.inner_content = args.first || '' end if xrb.inner_content.is_a?(String) && ! xrb.inner_content.html_safe? xrb.inner_content = xrb.inner_content.html_safe end xrb end |
#ui_group(xrb) ⇒ Object
47 48 49 50 51 |
# File 'app/helpers/ui_helper.rb', line 47 def ui_group(xrb) xrb.content = ui_output do xrb.inner_content end end |
#ui_image_block(xrb) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/helpers/ui_helper.rb', line 19 def ui_image_block(xrb) image = xrb.components.shift group = xrb.components.shift title = group.components.shift contents = group.components.shift ui_output do <<-HTML <div class="image-block"> <div class="image">#{image}</div> <div class="content"> <div class="title">#{title}</div> #{contents} </div> </div> <div class="clear"></div> HTML end end |
#ui_link(xrb) ⇒ Object
39 40 41 42 43 44 45 |
# File 'app/helpers/ui_helper.rb', line 39 def ui_link(xrb) xrb.attributes[:href] = xrb.attributes[:link] if xrb.attributes[:link] xrb.content = ui_output do content_tag(:a, xrb.inner_content, xrb.attributes) end end |
#ui_output ⇒ Object
helper
54 55 56 57 58 |
# File 'app/helpers/ui_helper.rb', line 54 def ui_output value = yield value.html_safe end |