Sha256: 7b23d3d12fcfc39df82d05b33e059adadb98654371be26f6f91b445cd471c145

Contents?: true

Size: 632 Bytes

Versions: 10

Compression:

Stored size: 632 Bytes

Contents

require 'liquid'

module Epubber::Services
  class Template
    # Compiles and renderes a template file in the given context
    def parse(file:, context:)
      compile(file).render context
    end

    # Compiles a file and returns a template instance ready to be rendered
    def compile(file)
      Liquid::Template.parse load(file)
    end

    # Returns the full path for a given template file
    def path(file)
      File.join File.dirname(__FILE__), '../../templates/', file
    end

  protected

    # Opens a file from disk located inside ./templates
    def load(file)
      File.open(path(file)).read
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
epubber-0.2.0 lib/epubber/services/template.rb
epubber-0.1.5 lib/epubber/services/template.rb
epubber-0.1.4 lib/epubber/services/template.rb
epubber-0.1.3 lib/epubber/services/template.rb
epubber-0.1.2 lib/epubber/services/template.rb
epubber-0.1.1 lib/epubber/services/template.rb
epubber-0.1.0 lib/epubber/services/template.rb
epubber-0.0.4 lib/epubber/services/template.rb
epubber-0.0.3 lib/epubber/services/template.rb
epubber-0.0.2 lib/epubber/services/template.rb