Sha256: b6dcd53543b757c40cebf8cb16a984a2f9a04a08ac725c190cb0efd800d35b02
Contents?: true
Size: 878 Bytes
Versions: 8
Compression:
Stored size: 878 Bytes
Contents
require 'volt/page/bindings/base_binding' class ContentBinding < BaseBinding def initialize(page, target, context, binding_name, getter) # puts "New Content Binding: #{self.inspect}" super(page, target, context, binding_name) # Listen for changes @computation = -> do begin update(@context.instance_eval(&getter)) rescue => e Volt.logger.error("ContentBinding Error: #{e.inspect}") update('') end end.watch! end def update(value) # TODORW: value = value.nil? ? '' : value # Exception values display the exception as a string value = value.to_s # Update the html in this section # TODO: Move the formatter into another class. dom_section.html = value.gsub("\n", "<br />\n") end def remove @computation.stop if @computation @computation = nil super end end
Version data entries
8 entries across 8 versions & 1 rubygems