Class: Avo::HTML::Builder
- Inherits:
-
Object
- Object
- Avo::HTML::Builder
- Defined in:
- lib/avo/html/builder.rb
Instance Attribute Summary collapse
-
#classes_stack ⇒ Object
Returns the value of attribute classes_stack.
-
#content_stack ⇒ Object
Returns the value of attribute content_stack.
-
#data_stack ⇒ Object
Returns the value of attribute data_stack.
-
#edit_stack ⇒ Object
Returns the value of attribute edit_stack.
-
#index_stack ⇒ Object
Returns the value of attribute index_stack.
-
#input_stack ⇒ Object
Returns the value of attribute input_stack.
-
#label_stack ⇒ Object
Returns the value of attribute label_stack.
-
#record ⇒ Object
Returns the value of attribute record.
-
#resource ⇒ Object
Returns the value of attribute resource.
-
#show_stack ⇒ Object
Returns the value of attribute show_stack.
-
#style_stack ⇒ Object
Returns the value of attribute style_stack.
-
#wrapper_stack ⇒ Object
Returns the value of attribute wrapper_stack.
Class Method Summary collapse
Instance Method Summary collapse
-
#build ⇒ Object
Fetch the menu.
-
#classes(payload = nil, &block) ⇒ Object
payload or block.
-
#content(&block) ⇒ Object
Takes a block.
-
#data(payload = nil, &block) ⇒ Object
payload or block.
- #dig_stack(*names) ⇒ Object
-
#edit(&block) ⇒ Object
Takes a block.
- #get_stack(name = nil) ⇒ Object
-
#index(&block) ⇒ Object
Takes a block.
-
#initialize(record: nil, resource: nil) ⇒ Builder
constructor
A new instance of Builder.
-
#input(&block) ⇒ Object
Takes a block.
-
#label(&block) ⇒ Object
Takes a block.
-
#show(&block) ⇒ Object
Takes a block.
-
#style(payload = nil, &block) ⇒ Object
payload or block.
-
#wrapper(&block) ⇒ Object
Takes a block.
Constructor Details
#initialize(record: nil, resource: nil) ⇒ Builder
Returns a new instance of Builder.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/avo/html/builder.rb', line 26 def initialize(record: nil, resource: nil) @wrapper_stack = {} @data_stack = {} @style_stack = "" @classes_stack = "" @show_stack = {} @edit_stack = {} @index_stack = {} @input_stack = {} @label_stack = {} @content_stack = {} @record = record @resource = resource end |
Instance Attribute Details
#classes_stack ⇒ Object
Returns the value of attribute classes_stack.
11 12 13 |
# File 'lib/avo/html/builder.rb', line 11 def classes_stack @classes_stack end |
#content_stack ⇒ Object
Returns the value of attribute content_stack.
17 18 19 |
# File 'lib/avo/html/builder.rb', line 17 def content_stack @content_stack end |
#data_stack ⇒ Object
Returns the value of attribute data_stack.
9 10 11 |
# File 'lib/avo/html/builder.rb', line 9 def data_stack @data_stack end |
#edit_stack ⇒ Object
Returns the value of attribute edit_stack.
13 14 15 |
# File 'lib/avo/html/builder.rb', line 13 def edit_stack @edit_stack end |
#index_stack ⇒ Object
Returns the value of attribute index_stack.
14 15 16 |
# File 'lib/avo/html/builder.rb', line 14 def index_stack @index_stack end |
#input_stack ⇒ Object
Returns the value of attribute input_stack.
15 16 17 |
# File 'lib/avo/html/builder.rb', line 15 def input_stack @input_stack end |
#label_stack ⇒ Object
Returns the value of attribute label_stack.
16 17 18 |
# File 'lib/avo/html/builder.rb', line 16 def label_stack @label_stack end |
#record ⇒ Object
Returns the value of attribute record.
19 20 21 |
# File 'lib/avo/html/builder.rb', line 19 def record @record end |
#resource ⇒ Object
Returns the value of attribute resource.
20 21 22 |
# File 'lib/avo/html/builder.rb', line 20 def resource @resource end |
#show_stack ⇒ Object
Returns the value of attribute show_stack.
12 13 14 |
# File 'lib/avo/html/builder.rb', line 12 def show_stack @show_stack end |
#style_stack ⇒ Object
Returns the value of attribute style_stack.
10 11 12 |
# File 'lib/avo/html/builder.rb', line 10 def style_stack @style_stack end |
#wrapper_stack ⇒ Object
Returns the value of attribute wrapper_stack.
8 9 10 |
# File 'lib/avo/html/builder.rb', line 8 def wrapper_stack @wrapper_stack end |
Class Method Details
.parse_block(record: nil, resource: nil, &block) ⇒ Object
3 4 5 |
# File 'lib/avo/html/builder.rb', line 3 def parse_block(record: nil, resource: nil, &block) Docile.dsl_eval(Avo::HTML::Builder.new(record: record, resource: resource), &block).build end |
Instance Method Details
#build ⇒ Object
Fetch the menu
110 111 112 |
# File 'lib/avo/html/builder.rb', line 110 def build self end |
#classes(payload = nil, &block) ⇒ Object
payload or block
70 71 72 |
# File 'lib/avo/html/builder.rb', line 70 def classes(payload = nil, &block) assign_property :classes, payload, &block end |
#content(&block) ⇒ Object
Takes a block
90 91 92 |
# File 'lib/avo/html/builder.rb', line 90 def content(&block) capture_block :content, &block end |
#data(payload = nil, &block) ⇒ Object
payload or block
60 61 62 |
# File 'lib/avo/html/builder.rb', line 60 def data(payload = nil, &block) assign_property :data, payload, &block end |
#dig_stack(*names) ⇒ Object
49 50 51 52 53 54 55 56 57 |
# File 'lib/avo/html/builder.rb', line 49 def dig_stack(*names) value = get_stack names.shift if value.is_a? self.class value.dig_stack(*names) else value end end |
#edit(&block) ⇒ Object
Takes a block
100 101 102 |
# File 'lib/avo/html/builder.rb', line 100 def edit(&block) capture_block :edit, &block end |
#get_stack(name = nil) ⇒ Object
42 43 44 45 46 47 |
# File 'lib/avo/html/builder.rb', line 42 def get_stack(name = nil) # We don't have an edit component for new so we should use edit name = :edit if name == :new send "#{name}_stack" end |
#index(&block) ⇒ Object
Takes a block
105 106 107 |
# File 'lib/avo/html/builder.rb', line 105 def index(&block) capture_block :index, &block end |
#input(&block) ⇒ Object
Takes a block
80 81 82 |
# File 'lib/avo/html/builder.rb', line 80 def input(&block) capture_block :input, &block end |
#label(&block) ⇒ Object
Takes a block
85 86 87 |
# File 'lib/avo/html/builder.rb', line 85 def label(&block) capture_block :label, &block end |
#show(&block) ⇒ Object
Takes a block
95 96 97 |
# File 'lib/avo/html/builder.rb', line 95 def show(&block) capture_block :show, &block end |
#style(payload = nil, &block) ⇒ Object
payload or block
65 66 67 |
# File 'lib/avo/html/builder.rb', line 65 def style(payload = nil, &block) assign_property :style, payload, &block end |
#wrapper(&block) ⇒ Object
Takes a block
75 76 77 |
# File 'lib/avo/html/builder.rb', line 75 def wrapper(&block) capture_block :wrapper, &block end |