Class: Broadway::Layout

Inherits:
Object
  • Object
show all
Defined in:
lib/broadway/resources/layout.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Layout

Returns a new instance of Layout.



5
6
7
# File 'lib/broadway/resources/layout.rb', line 5

def initialize(attributes)
  
end

Instance Attribute Details

#actionObject

Returns the value of attribute action.



3
4
5
# File 'lib/broadway/resources/layout.rb', line 3

def action
  @action
end

#fileObject

Returns the value of attribute file.



3
4
5
# File 'lib/broadway/resources/layout.rb', line 3

def file
  @file
end

#resourceObject

Returns the value of attribute resource.



3
4
5
# File 'lib/broadway/resources/layout.rb', line 3

def resource
  @resource
end

Instance Method Details

#kindObject



20
21
22
23
24
25
26
# File 'lib/broadway/resources/layout.rb', line 20

def kind
  if file.extension =~ /(haml|erb)/
    $1
  else
    "file"
  end
end

#template(theme = "") ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/broadway/resources/layout.rb', line 9

def template(theme = "")
  # first check if it's in the posts directory (where textile files are)
  path = File.join(file.directory, action).squeeze("/")
  exists = false
  extensions = %w(html haml erb html.haml html.erb)
  extensions.each do |ext|
    exists = true if File.exists?("#{path}.#{ext}")
  end
  path if exists
end