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.
-
#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.
-
#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.
-
#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.
-
#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.
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/avo/html/builder.rb', line 24 def initialize(record: nil, resource: nil) @wrapper_stack = {} @data_stack = {} @style_stack = "" @classes_stack = "" @show_stack = {} @edit_stack = {} @index_stack = {} @input_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 |
#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 |
#record ⇒ Object
Returns the value of attribute record.
17 18 19 |
# File 'lib/avo/html/builder.rb', line 17 def record @record end |
#resource ⇒ Object
Returns the value of attribute resource.
18 19 20 |
# File 'lib/avo/html/builder.rb', line 18 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
96 97 98 |
# File 'lib/avo/html/builder.rb', line 96 def build self end |
#classes(payload = nil, &block) ⇒ Object
payload or block
66 67 68 |
# File 'lib/avo/html/builder.rb', line 66 def classes(payload = nil, &block) assign_property :classes, payload, &block end |
#data(payload = nil, &block) ⇒ Object
payload or block
56 57 58 |
# File 'lib/avo/html/builder.rb', line 56 def data(payload = nil, &block) assign_property :data, payload, &block end |
#dig_stack(*names) ⇒ Object
45 46 47 48 49 50 51 52 53 |
# File 'lib/avo/html/builder.rb', line 45 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
86 87 88 |
# File 'lib/avo/html/builder.rb', line 86 def edit(&block) capture_block :edit, &block end |
#get_stack(name = nil) ⇒ Object
38 39 40 41 42 43 |
# File 'lib/avo/html/builder.rb', line 38 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
91 92 93 |
# File 'lib/avo/html/builder.rb', line 91 def index(&block) capture_block :index, &block end |
#input(&block) ⇒ Object
Takes a block
76 77 78 |
# File 'lib/avo/html/builder.rb', line 76 def input(&block) capture_block :input, &block end |
#show(&block) ⇒ Object
Takes a block
81 82 83 |
# File 'lib/avo/html/builder.rb', line 81 def show(&block) capture_block :show, &block end |
#style(payload = nil, &block) ⇒ Object
payload or block
61 62 63 |
# File 'lib/avo/html/builder.rb', line 61 def style(payload = nil, &block) assign_property :style, payload, &block end |
#wrapper(&block) ⇒ Object
Takes a block
71 72 73 |
# File 'lib/avo/html/builder.rb', line 71 def wrapper(&block) capture_block :wrapper, &block end |