Module: Sinatra::Partial::Private

Defined in:
lib/sinatra/partial.rb

Overview

This is here to make testing the private code easier while not including it in the helpers.

Class Method Summary collapse

Class Method Details

.partial_expand_path(partial_path, underscores = false) ⇒ Object

This gets the path to the template, taking into account whether leading underscores are needed.

param [String] partial_path param [true,false,nil] underscores Defaults to false



15
16
17
18
19
20
# File 'lib/sinatra/partial.rb', line 15

def self.partial_expand_path(partial_path, underscores=false)
  underscores ||= false
  dirs, base = [File.dirname(partial_path),File.basename(partial_path)]
  base.insert(0, "_") if underscores
  File.join(dirs, base).to_sym
end

.partial_local(partial_path) ⇒ Object

This takes the name of the local from the template’s name, and corrects local by removing leading underscore if it’s there. param [String] partial_path



25
26
27
28
# File 'lib/sinatra/partial.rb', line 25

def self.partial_local(partial_path)
  partial_path = partial_path[1..-1] if partial_path.start_with? "_"
  File.basename(partial_path).to_sym
end