Sha256: aacc4531a29c6a3c4193f69a2bbad9962023929af1d52b5bb1f5338f7bf92b61
Contents?: true
Size: 1.47 KB
Versions: 7
Compression:
Stored size: 1.47 KB
Contents
require File.join(File.dirname(__FILE__), 'file_base') module Mack module Rendering # :nodoc: module Type # :nodoc: # Used to render partials. Partials are small reusable templates. They have to start with an _. # # Example: # <%= render(:partial, "users/form") %> # => /users/_form.html.erb class Partial < Mack::Rendering::Type::FileBase # See Mack::Rendering::Type::FileBase render_file for more information. # # The path to the file is built like such: # app/views/#{controller name}/#{partial name with prefixed _}.#{format (html, xml, js, etc...)}.#{extension defined in the engine} # Example: # app/views/users/_form.html.erb def render partial = self.render_value.to_s parts = partial.split("/") if parts.size == 1 # it's local to this controller partial = "_" << partial partial = File.join(self.controller_view_path, partial) else # it's elsewhere parts[parts.size - 1] = "_" << parts.last partial = File.join(Mack.root, "app", "views", parts) end partial = "#{partial}.#{self.options[:format]}" render_file(partial, :partial) end # No layouts should be used with this Mack::Rendering::Type def allow_layout? false end end # Partial end # Type end # Rendering end # Mack
Version data entries
7 entries across 7 versions & 1 rubygems