Class: Jav::HTML::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/jav/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.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/jav/html/builder.rb', line 14

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.



8
9
10
# File 'lib/jav/html/builder.rb', line 8

def classes_stack
  @classes_stack
end

#content_stackObject

Returns the value of attribute content_stack.



8
9
10
# File 'lib/jav/html/builder.rb', line 8

def content_stack
  @content_stack
end

#data_stackObject

Returns the value of attribute data_stack.



8
9
10
# File 'lib/jav/html/builder.rb', line 8

def data_stack
  @data_stack
end

#edit_stackObject

Returns the value of attribute edit_stack.



8
9
10
# File 'lib/jav/html/builder.rb', line 8

def edit_stack
  @edit_stack
end

#index_stackObject

Returns the value of attribute index_stack.



8
9
10
# File 'lib/jav/html/builder.rb', line 8

def index_stack
  @index_stack
end

#input_stackObject

Returns the value of attribute input_stack.



8
9
10
# File 'lib/jav/html/builder.rb', line 8

def input_stack
  @input_stack
end

#label_stackObject

Returns the value of attribute label_stack.



8
9
10
# File 'lib/jav/html/builder.rb', line 8

def label_stack
  @label_stack
end

#recordObject

Returns the value of attribute record.



8
9
10
# File 'lib/jav/html/builder.rb', line 8

def record
  @record
end

#resourceObject

Returns the value of attribute resource.



8
9
10
# File 'lib/jav/html/builder.rb', line 8

def resource
  @resource
end

#show_stackObject

Returns the value of attribute show_stack.



8
9
10
# File 'lib/jav/html/builder.rb', line 8

def show_stack
  @show_stack
end

#style_stackObject

Returns the value of attribute style_stack.



8
9
10
# File 'lib/jav/html/builder.rb', line 8

def style_stack
  @style_stack
end

#wrapper_stackObject

Returns the value of attribute wrapper_stack.



8
9
10
# File 'lib/jav/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/jav/html/builder.rb', line 3

def parse_block(record: nil, resource: nil, &block)
  Docile.dsl_eval(Jav::HTML::Builder.new(record: record, resource: resource), &block).build
end

Instance Method Details

#buildObject

Fetch the menu



98
99
100
# File 'lib/jav/html/builder.rb', line 98

def build
  self
end

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

payload or block



58
59
60
# File 'lib/jav/html/builder.rb', line 58

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

#content(&block) ⇒ Object

Takes a block



78
79
80
# File 'lib/jav/html/builder.rb', line 78

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

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

payload or block



48
49
50
# File 'lib/jav/html/builder.rb', line 48

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

#dig_stack(*names) ⇒ Object



37
38
39
40
41
42
43
44
45
# File 'lib/jav/html/builder.rb', line 37

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



88
89
90
# File 'lib/jav/html/builder.rb', line 88

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

#get_stack(name = nil) ⇒ Object



30
31
32
33
34
35
# File 'lib/jav/html/builder.rb', line 30

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



93
94
95
# File 'lib/jav/html/builder.rb', line 93

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

#input(&block) ⇒ Object

Takes a block



68
69
70
# File 'lib/jav/html/builder.rb', line 68

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

#label(&block) ⇒ Object

Takes a block



73
74
75
# File 'lib/jav/html/builder.rb', line 73

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

#show(&block) ⇒ Object

Takes a block



83
84
85
# File 'lib/jav/html/builder.rb', line 83

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

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

payload or block



53
54
55
# File 'lib/jav/html/builder.rb', line 53

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

#wrapper(&block) ⇒ Object

Takes a block



63
64
65
# File 'lib/jav/html/builder.rb', line 63

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