Sha256: a64045d03daeeb3becd08616b9640c59dcdcedd7721a5f6f030c8d9e156422d2

Contents?: true

Size: 909 Bytes

Versions: 1

Compression:

Stored size: 909 Bytes

Contents

require 'malt/formats/abstract_template'
require 'malt/formats/html'
require 'malt/engines/tenjin'

module Malt::Format

  # Tenjin
  #
  #   http://www.kuwata-lab.com/tenjin/
  #
  class Tenjin < AbstractTemplate

    register 'tenjin'

    def rb
      render_engine.compile(text, file)
    end

    # Erb templates can be "precompiled" into Ruby templates.
    def to_rb
      text = rb
      Ruby.new(:text=>text, :file=>refile(:rb), :type=>:rb)
    end

    alias_method(:to_ruby, :to_rb)

    #
    def html
      render(:html, data, &yld)
    end

    #
    def to_html(data, &yld)
      new_text    = render(:html, data, &yld)
      new_file    = refile(:html)
      new_options = options.merge(:text=>new_text, :file=>new_file, :type=>:html)
      HTML.new(new_options)
    end

    private

    #
    def render_engine
      @render_engine ||= Malt::Engine::Tenjin.new(options)
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
malt-0.1.1 lib/malt/formats/tenjin.rb