class Epuber::RubyTemplater
Attributes
file_path[RW]
@return [String]
locals[RW]
@return [Hash]
source_text[RW]
@return [String]
Public Class Methods
from_file(file)
click to toggle source
@param file [String, File]
@return [self]
# File lib/epuber/vendor/ruby_templater.rb, line 37 def self.from_file(file) file_obj = if file.is_a?(String) File.new(file, 'r') else file end from_source(file_obj.read, file_obj.path) end
from_source(source, file_path = nil)
click to toggle source
@param source [String]
@return [self]
# File lib/epuber/vendor/ruby_templater.rb, line 26 def self.from_source(source, file_path = nil) inst = new inst.source_text = source inst.file_path = file_path inst end
Public Instance Methods
render()
click to toggle source
@return [String]
# File lib/epuber/vendor/ruby_templater.rb, line 63 def render hash_binding = HashBinding.new(locals) eval_string = %(%(#{source_text})) eval(eval_string, hash_binding.get_binding) end
with_locals(locals = {})
click to toggle source
@param locals [Hash]
@return [self]
# File lib/epuber/vendor/ruby_templater.rb, line 56 def with_locals(locals = {}) self.locals = locals self end