Class: AbstractInterface::ViewBuilder
- Inherits:
-
Object
- Object
- AbstractInterface::ViewBuilder
- Defined in:
- lib/abstract_interface/view_builder.rb
Instance Attribute Summary collapse
-
#template ⇒ Object
readonly
Returns the value of attribute template.
Class Method Summary collapse
Instance Method Summary collapse
- #form_for(*args, &block) ⇒ Object
-
#form_tag(*args, &block) ⇒ Object
Forms.
-
#initialize(template) ⇒ ViewBuilder
constructor
A new instance of ViewBuilder.
-
#options(*args, &block) ⇒ Object
Builders.
Constructor Details
#initialize(template) ⇒ ViewBuilder
Returns a new instance of ViewBuilder.
19 20 21 |
# File 'lib/abstract_interface/view_builder.rb', line 19 def initialize template @template = template end |
Instance Attribute Details
#template ⇒ Object (readonly)
Returns the value of attribute template.
18 19 20 |
# File 'lib/abstract_interface/view_builder.rb', line 18 def template @template end |
Class Method Details
.generate_helper_methods(methods) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/abstract_interface/view_builder.rb', line 4 def self.generate_helper_methods methods methods.each do |folder, templates| templates.each do |template| code = %{\ def #{template} *args, &block render_haml_builder "#{folder}", "#{template}", *args, &block end} eval code, binding, __FILE__, __LINE__ end end end |
Instance Method Details
#form_for(*args, &block) ⇒ Object
72 73 74 75 76 77 78 79 80 |
# File 'lib/abstract_interface/view_builder.rb', line 72 def form_for *args, &block model_helper, = template. *args form_tag do |themed_form_helper| model_helper.form_helper = themed_form_helper block.call model_helper if block end end |
#form_tag(*args, &block) ⇒ Object
Forms
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/abstract_interface/view_builder.rb', line 56 def form_tag *args, &block f = ThemedFormHelper.new(template) content = block ? capture{block.call(f)} : "" html = render( themed_partial('forms/form'), :object => {:form_attributes => , :content => content}.to_openobject ) if block template.concat html else html end end |
#options(*args, &block) ⇒ Object
Builders
44 45 46 47 48 49 50 |
# File 'lib/abstract_interface/view_builder.rb', line 44 def *args, &block opt = args. args.size.must_be.in 0..1 opt[:content] = args.first if args.size == 1 AbstractInterface::HamlBuilder.get_input self.template, opt, &block end |