Sha256: 9193722e9d8bffc5ea96bd80a2c4e4835071c5e0dfc210e3126046ca33079387

Contents?: true

Size: 601 Bytes

Versions: 7

Compression:

Stored size: 601 Bytes

Contents

require 'slim'

module TurnipFormatter
  module Printer
    #
    # @example
    #   render_template(:main, { name: 'user' })
    #     # => Tilt.new('/path/to/main.erb') render { name: 'user' }
    #
    def render_template(name, params = {})
      render_template_list(name).render(self, params)
    end

  private

    def render_template_list(name)
      if templates[name].nil?
        path = File.dirname(__FILE__) + "/template/#{name}.slim"
        templates[name] = Slim::Template.new(path)
      end

      templates[name]
    end

    def templates
      @templates ||= {}
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
turnip_formatter-0.6.0.pre.beta.2 lib/turnip_formatter/printer.rb
turnip_formatter-0.6.0.pre.beta.1 lib/turnip_formatter/printer.rb
turnip_formatter-0.5.0 lib/turnip_formatter/printer.rb
turnip_formatter-0.4.0 lib/turnip_formatter/printer.rb
turnip_formatter-0.3.4 lib/turnip_formatter/printer.rb
turnip_formatter-0.3.3 lib/turnip_formatter/printer.rb
turnip_formatter-0.3.2 lib/turnip_formatter/printer.rb