Sha256: 8607a64b6cdfcaccfb8451d70f4fdcb3b4f8496432356f58101566772ab73bed

Contents?: true

Size: 752 Bytes

Versions: 7

Compression:

Stored size: 752 Bytes

Contents

require 'tenjin'

module Ramaze
  module View
    module Tenjin
      def self.call(action, string)
        template = ::Tenjin::Template.new
        template.convert(string)

        html = template.ramaze_render(action.binding)

        return html, 'text/html'
      end
    end
  end
end

module Tenjin
  class Template
    # This method allows us to use tenjin with a binding, so helper methods are
    # available instead of only instance variables.
    # The big issue with this approach is that the original
    # Tenjin::ContextHelper is not available here. Patches welcome.
    def ramaze_render(binding)
      code = "_buf = #{init_buf_expr}; #{@script}; _buf.to_s"
      _buf = binding.eval(code, @filename || '(tenjin)')
    end
  end
end

Version data entries

7 entries across 7 versions & 3 rubygems

Version Path
Pistos-ramaze-2009.04.08 lib/ramaze/view/tenjin.rb
manveru-ramaze-2009.04.01 lib/ramaze/view/tenjin.rb
manveru-ramaze-2009.04.08 lib/ramaze/view/tenjin.rb
manveru-ramaze-2009.04.18 lib/ramaze/view/tenjin.rb
manveru-ramaze-2009.04.22 lib/ramaze/view/tenjin.rb
manveru-ramaze-2009.04 lib/ramaze/view/tenjin.rb
ramaze-2009.04 lib/ramaze/view/tenjin.rb