Sha256: e5b9db2d9df914efc7581d9b07a0b03d10ed4a5f9993a45c42c34448545b3b0d
Contents?: true
Size: 1.59 KB
Versions: 3
Compression:
Stored size: 1.59 KB
Contents
# Base Module for Padrino ViewModels. # module ViewModels # Base class from which all view_models inherit. # class Base # Make helper and helper_method available # # TODO Rewrite Padrino style. # # include ActionController::Helpers class << self # Alias the context_method to the padrino-centric app_method. # alias app_method context_method # Sets the view format and tries to render the given options. # # Note: Also caches [path, name, format] => template path. # def render renderer, options # options.format! view renderer.instance_variable_set(:@_content_type, options.format || :html) path_store.cached options do path = template_path renderer, options options.file = path renderer.send :render, path.to_s, options.to_render_options end end # FIXME Need to use padrino register for this. # alias_method :register, :include protected # Accesses the view to find a suitable template path. # # Returns nil if a template cannot be found. # def template_path_from renderer, options template = renderer.send :resolve_template, tentative_template_path(options) # TODO! # template && template.first.to_s # was .path rescue Padrino::Rendering::TemplateNotFound => t nil end end alias app context protected def renderer app end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
view_models-2.0.1 | lib/padrino/lib/view_models/base.rb |
view_models-2.0.0.ruby19 | lib/padrino/lib/view_models/base.rb |
view_models-2.0.0 | lib/padrino/lib/view_models/base.rb |