Action View TemplatePath

Represents a template path within ActionView’s lookup and rendering system, like “users/show”

TemplatePath makes it convenient to convert between separate name, prefix, partial arguments and the virtual path.

Methods

Attributes

[R] name
[R] partial
[R] partial?
[R] prefix
[R] to_s
[R] to_str
[R] virtual
[R] virtual_path

Class Public methods

build(name, prefix, partial)

Convert name, prefix, and partial into a TemplatePath

📝 Source code
# File actionview/lib/action_view/template_path.rb, line 43
    def self.build(name, prefix, partial)
      new name, prefix, partial, virtual(name, prefix, partial)
    end
🔎 See on GitHub

new(name, prefix, partial, virtual)

📝 Source code
# File actionview/lib/action_view/template_path.rb, line 47
    def initialize(name, prefix, partial, virtual)
      @name    = name
      @prefix  = prefix
      @partial = partial
      @virtual = virtual
    end
🔎 See on GitHub

parse(virtual)

Build a TemplatePath form a virtual path

📝 Source code
# File actionview/lib/action_view/template_path.rb, line 28
    def self.parse(virtual)
      if nameidx = virtual.rindex("/")
        prefix = virtual[0, nameidx]
        name = virtual.from(nameidx + 1)
        prefix = prefix[1..] if prefix.start_with?("/")
      else
        prefix = ""
        name = virtual
      end
      partial = name.start_with?("_")
      name = name[1..] if partial
      new name, prefix, partial, virtual
    end
🔎 See on GitHub

virtual(name, prefix, partial)

Convert name, prefix, and partial into a virtual path string

📝 Source code
# File actionview/lib/action_view/template_path.rb, line 17
    def self.virtual(name, prefix, partial)
      if prefix.empty?
        "#{partial ? "_" : ""}#{name}"
      elsif partial
        "#{prefix}/_#{name}"
      else
        "#{prefix}/#{name}"
      end
    end
🔎 See on GitHub