Sha256: bbb0072a71f8048d4dd13b1533e1f273804fb973b8b733e20c44890a9ce4a7e6
Contents?: true
Size: 1.22 KB
Versions: 3
Compression:
Stored size: 1.22 KB
Contents
module Apotomo # Shortcut methods for creating widget trees. module WidgetShortcuts # Creates an instance of <tt>class_name</tt> with the id <tt>id</tt> and start state <tt>state</tt>. # Default start state is <tt>:display</tt>. # Yields self if a block is passed. # Example: # widget(:form, 'uploads', :build_form) do |form| # form << widget(:upload_field) # # You can also use namespaces. # # widget('jquery/tabs', 'panel') def widget(class_name, id, state=:display, *args) object = constant_for(class_name).new(id, state, *args) yield object if block_given? object end def container(id, *args, &block) widget('apotomo/container_widget', id, *args, &block) end def section(*args) container(*args) end def cell(base_name, states, id, *args) widget(base_name.to_s + '_cell', states, id, *args) end def tab_panel(id, *args) widget('apotomo/tab_panel_widget', :display, id, *args) end def tab(id, *args) widget('apotomo/tab_widget', :display, id, *args) end private def constant_for(class_name) class_name.to_s.camelize.constantize end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
apotomo-0.1.4 | lib/apotomo/widget_shortcuts.rb |
apotomo-0.1.3 | lib/apotomo/widget_shortcuts.rb |
apotomo-0.1.2 | lib/apotomo/widget_shortcuts.rb |