Class: Volt::TextareaScope

Inherits:
ViewScope show all
Defined in:
lib/volt/server/html_parser/textarea_scope.rb

Instance Attribute Summary

Attributes inherited from ViewScope

#binding_number, #bindings, #html, #path

Instance Method Summary collapse

Methods inherited from ViewScope

#<<, #add_component, #add_content_binding, #add_each, #add_else, #add_if, #add_template, #add_textarea, #last_method_name, #parent_fetcher, #save_binding

Methods included from AttributeScope

#add_id_to_attributes, #add_multiple_attribute, #add_single_attribute, #add_string_template_renderer, #attribute_string, #binding_parts_and_count, #getter_to_setter, #process_attribute, #process_attributes, #process_event_binding

Constructor Details

#initialize(handler, path, attributes) ⇒ TextareaScope

Returns a new instance of TextareaScope.



3
4
5
6
7
# File 'lib/volt/server/html_parser/textarea_scope.rb', line 3

def initialize(handler, path, attributes)
  super(handler, path)

  @attributes = attributes
end

Instance Method Details

#add_binding(content) ⇒ Object



9
10
11
# File 'lib/volt/server/html_parser/textarea_scope.rb', line 9

def add_binding(content)
  @html << "{{#{content}}}"
end

#close_scope(pop = true) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/volt/server/html_parser/textarea_scope.rb', line 13

def close_scope(pop = true)
  # Remove from the scope
  @handler.scope.pop

  attributes = @attributes

  if @html[/\{\{[^\}]+\}\}/]
    # If the html inside the textarea has a binding, process it as
    # a value attribute.
    attributes['value'] = @html
    @html               = ''
  end

  # Normal tag
  attributes = @handler.last.process_attributes('textarea', attributes)

  @handler.last.html << "<textarea#{attribute_string(attributes)}>#{@html}</textarea>"
end