module Apotomo::WidgetShortcuts
Public Instance Methods
widget(*args, &block)
click to toggle source
Shortcut for creating an instance of class_name+"_widget"
named id
. Yields self. Note that this creates a proxy object, only. The actual widget is built not until you added it, e.g. using <<.
Example:
root << widget(:comments)
will create a CommentsWidget
with id :comments attached to root
.
widget(:comments, 'post-comments', :user => current_user)
sets id to ‘posts_comments’ and options to the hash.
You can also use namespaces.
widget('jquery/tabs', 'panel')
Add a block if you need to grab the created widget right away.
root << widget(:comments) do |comments| comments.markdown! end
Using widget
is just a shortcut, you can always use the constructor as well.
CommentsWidget.new(root, :comments)
# File lib/apotomo/widget_shortcuts.rb, line 31 def widget(*args, &block) FactoryProxy.new(*args, &block) end