Class: Avo::HTML::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/avo/html/builder.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(record: nil, resource: nil) ⇒ Builder

Returns a new instance of Builder.



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/avo/html/builder.rb', line 30

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_stackObject

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_stackObject

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_stackObject

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_stackObject

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_stackObject

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_stackObject

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_stackObject

Returns the value of attribute label_stack.



16
17
18
# File 'lib/avo/html/builder.rb', line 16

def label_stack
  @label_stack
end

#recordObject

Returns the value of attribute record.



19
20
21
# File 'lib/avo/html/builder.rb', line 19

def record
  @record
end

#resourceObject

Returns the value of attribute resource.



20
21
22
# File 'lib/avo/html/builder.rb', line 20

def resource
  @resource
end

#show_stackObject

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_stackObject

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_stackObject

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

#buildObject

Fetch the menu



114
115
116
# File 'lib/avo/html/builder.rb', line 114

def build
  self
end

#classes(payload = nil, &block) ⇒ Object

payload or block



74
75
76
# File 'lib/avo/html/builder.rb', line 74

def classes(payload = nil, &block)
  assign_property :classes, payload, &block
end

#content(&block) ⇒ Object

Takes a block



94
95
96
# File 'lib/avo/html/builder.rb', line 94

def content(&block)
  capture_block :content, &block
end

#current_userObject



26
27
28
# File 'lib/avo/html/builder.rb', line 26

def current_user
  Avo::Current.user
end

#data(payload = nil, &block) ⇒ Object

payload or block



64
65
66
# File 'lib/avo/html/builder.rb', line 64

def data(payload = nil, &block)
  assign_property :data, payload, &block
end

#dig_stack(*names) ⇒ Object



53
54
55
56
57
58
59
60
61
# File 'lib/avo/html/builder.rb', line 53

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



104
105
106
# File 'lib/avo/html/builder.rb', line 104

def edit(&block)
  capture_block :edit, &block
end

#get_stack(name = nil) ⇒ Object



46
47
48
49
50
51
# File 'lib/avo/html/builder.rb', line 46

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



109
110
111
# File 'lib/avo/html/builder.rb', line 109

def index(&block)
  capture_block :index, &block
end

#input(&block) ⇒ Object

Takes a block



84
85
86
# File 'lib/avo/html/builder.rb', line 84

def input(&block)
  capture_block :input, &block
end

#label(&block) ⇒ Object

Takes a block



89
90
91
# File 'lib/avo/html/builder.rb', line 89

def label(&block)
  capture_block :label, &block
end

#show(&block) ⇒ Object

Takes a block



99
100
101
# File 'lib/avo/html/builder.rb', line 99

def show(&block)
  capture_block :show, &block
end

#style(payload = nil, &block) ⇒ Object

payload or block



69
70
71
# File 'lib/avo/html/builder.rb', line 69

def style(payload = nil, &block)
  assign_property :style, payload, &block
end

#wrapper(&block) ⇒ Object

Takes a block



79
80
81
# File 'lib/avo/html/builder.rb', line 79

def wrapper(&block)
  capture_block :wrapper, &block
end