class Volt::TextareaScope

Public Class Methods

new(handler, path, attributes) click to toggle source
Calls superclass method
# File lib/volt/server/html_parser/textarea_scope.rb, line 3
def initialize(handler, path, attributes)
  super(handler, path)

  @attributes = attributes
end

Public Instance Methods

add_binding(content) click to toggle source
# File lib/volt/server/html_parser/textarea_scope.rb, line 9
def add_binding(content)
  @html << "{{#{content}}}"
end
close_scope(pop = true) click to toggle source
# 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