class Rtprov::Template
Public Class Methods
find(router, name)
click to toggle source
# File lib/rtprov/template.rb, line 36 def self.find(router, name) candidates = [ "templates/#{router}/#{name}.erb", "templates/#{name}.erb", ] candidates.find do |candidate| return new(File.read(candidate)) if File.exist?(candidate) end raise "Template `#{name}` not found in #{candidates.inspect}" end
new(source)
click to toggle source
# File lib/rtprov/template.rb, line 49 def initialize(source) @erb = ERB.new(source, trim_mode: "-") end
Public Instance Methods
render(variables)
click to toggle source
# File lib/rtprov/template.rb, line 53 def render(variables) context = RenderingContext.new(variables) @erb.result(context.binding) end