Sha256: 1b41809eacae7635faa82d338dd6b1f2d12d77d0891aa845a6ad5fd0f64bc31f
Contents?: true
Size: 945 Bytes
Versions: 16
Compression:
Stored size: 945 Bytes
Contents
require 'volt/page/bindings/base_binding' module Volt 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) value = value.or('') # 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 end
Version data entries
16 entries across 16 versions & 1 rubygems