class Epubber::Services::Template

Public Instance Methods

compile(file) click to toggle source

Compiles a file and returns a template instance ready to be rendered

# File lib/epubber/services/template.rb, line 11
def compile(file)
  Liquid::Template.parse load(file)
end
parse(file:, context:) click to toggle source

Compiles and renderes a template file in the given context

# File lib/epubber/services/template.rb, line 6
def parse(file:, context:)
  compile(file).render context
end
path(file) click to toggle source

Returns the full path for a given template file

# File lib/epubber/services/template.rb, line 16
def path(file)
  File.join File.dirname(__FILE__), '../../templates/', file
end

Protected Instance Methods

load(file) click to toggle source

Opens a file from disk located inside ./templates

# File lib/epubber/services/template.rb, line 23
def load(file)
  File.open(path(file)).read
end