class DNote::Format::ErbScope
Evaluation scope for ERB templates
Public Class Methods
new(data = {})
click to toggle source
# File lib/dnote/format.rb, line 123 def initialize(data = {}) @data = data end
Public Instance Methods
h(string)
click to toggle source
# File lib/dnote/format.rb, line 133 def h(string) REXML::Text.normalize(string) end
method_missing(method, *_args)
click to toggle source
Calls superclass method
# File lib/dnote/format.rb, line 137 def method_missing(method, *_args) sym = method.to_sym return @data.fetch(sym) if @data.key? sym super end
render(file)
click to toggle source
# File lib/dnote/format.rb, line 127 def render(file) contents = File.read(file) erb = ERB.new(contents, trim_mode: "<>") erb.result(binding) end
respond_to_missing?(method)
click to toggle source
Calls superclass method
# File lib/dnote/format.rb, line 144 def respond_to_missing?(method) @data.key?(method.to_sym) || super end