Sha256: 298443775223a74a46062d5adbb29d5d514da6404d77eed173ddfe667c977591

Contents?: true

Size: 612 Bytes

Versions: 6

Compression:

Stored size: 612 Bytes

Contents

module Jason
  # Rails plugin for using Jason as a template handler.
  # 
  # Name your view templates like so: `view_name.jason`.
  # 
  # Jason loads this module only if it can find `ActionView`.
  class RailsTemplateHandler
    class_attribute :default_format
    self.default_format = Mime::JSON
    
    # Compile the Rails template.
    # 
    # @param [Class] template the Rails template class
    # @return [String] the compiled template
    def call(template)
      Jason.compile(template.source)
    end
  end
end

ActionView::Template.register_template_handler(:jason, Jason::RailsTemplateHandler.new)

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
jason-0.6.0 lib/jason/rails_template_handler.rb
jason-0.5.0 lib/jason/rails_template_handler.rb
jason-0.4.0 lib/jason/rails_template_handler.rb
jason-0.3.1 lib/jason/rails_template_handler.rb
jason-0.3.0 lib/jason/rails_template_handler.rb
jason-0.2.0 lib/jason/rails_template_handler.rb