Sha256: 2ea8121cebccf8d4efd56a07d1e4bd532442ca3bf751ca45b57a8e736df8d404

Contents?: true

Size: 1.06 KB

Versions: 29

Compression:

Stored size: 1.06 KB

Contents

require 'nagoro'
require 'ramaze/view/nagoro/render_partial'

module Ramaze
  module View
    # Binding to the Nagoro templating engine.
    #
    # To pipe your template through tidy you have to use:
    #
    #   Ramaze::View::Nagoro.options.tidy = true
    #
    # @see http://github.com/manveru/nagoro
    module Nagoro
      include Optioned

      options.dsl do
        o "Pipes to pass the template through",
          :pipes, ::Nagoro::DEFAULT_PIPES

        o "Use tidy to cleanup the rendered template",
          :tidy, false
      end

      def self.call(action, string)
        default_options = {
          :pipes     => options.pipes,
          :filename  => action.view,
          :binding   => action.binding,
          :variables => action.variables
        }

        render_options = default_options.merge(action.options)

        if options.tidy
          html = ::Nagoro.tidy_render(string.to_s, render_options)
        else
          html = ::Nagoro.render(string.to_s, render_options)
        end

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

Version data entries

29 entries across 29 versions & 4 rubygems

Version Path
ramaze-2010.03 lib/ramaze/view/nagoro.rb
ramaze-2010.01 lib/ramaze/view/nagoro.rb
ramaze-2009.10 lib/ramaze/view/nagoro.rb
ramaze-2009.07 lib/ramaze/view/nagoro.rb
ramaze-2009.05 lib/ramaze/view/nagoro.rb
ramaze-2009.04 lib/ramaze/view/nagoro.rb
ramaze-2009.06.12 lib/ramaze/view/nagoro.rb
ramaze-2009.06.04 lib/ramaze/view/nagoro.rb
ramaze-2009.06 lib/ramaze/view/nagoro.rb