Sha256: bfdebd24e2df3e0487351a73f825871121d4001e86d92d83eccae0a4f4ef638c

Contents?: true

Size: 875 Bytes

Versions: 1

Compression:

Stored size: 875 Bytes

Contents

require 'json'
require 'liquid'

module Eyemask
  module Core
    class Converter

      def initialize(initiaizer_options={})
        @template = ::Liquid::Template.parse(template(initiaizer_options[:template]))
      end

      def convert(document)
        @template.render(document, registers: document).strip
      end

      private

      def template(template)
        case template
        when "markdown"
          File.open(template_file("markdown.md")).read
        when "princexml"
          File.open(template_file("princexml.html")).read
        when "slides"
          File.open(template_file("slides.html")).read
        else
          File.open(File.expand_path(template)).read
        end
      end

      def template_file(filename)
        File.join(File.dirname(File.expand_path(__FILE__)), "../../../templates/#{filename}")
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
eyemask-0.1.0 lib/eyemask/core/converter.rb