Sha256: 8f77d7d0fcd7b968fe935e7a4eafafaf57327fb958f0ec4865e0936d934fb38e
Contents?: true
Size: 1011 Bytes
Versions: 6
Compression:
Stored size: 1011 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 res = @context.instance_eval(&getter) rescue => e Volt.logger.error("ContentBinding Error: #{e.inspect}") '' end end.watch_and_resolve! do |result| update(result) end end def update(value) value = 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.text = value.gsub("\n", "<br />\n") end def remove if @computation @computation.stop @computation = nil end super end end end
Version data entries
6 entries across 6 versions & 1 rubygems