Sha256: 8c251a91a71534523b5a255a4647ed56c1782820f1693b0711bbe0ee55ed12e4

Contents?: true

Size: 770 Bytes

Versions: 4

Compression:

Stored size: 770 Bytes

Contents

class Layout
  def self.all
    files.map do |layout|
      layout = layout.split('/').last.gsub(file_extension, '')
      [layout.titleize, layout]
    end
  end

  def self.files
    files = []
    SlicesController.view_paths.each do |resolver|
      query = File.join(resolver, 'layouts', "*#{file_extension}")
      files.concat(Dir.glob(query))
    end
    files.reject do |file|
      file.include?('admin.html.erb')
    end.uniq.sort
  end

  def self.file_extension
    '.html.erb'
  end

  def initialize(name)
    @name = name
  end

  def path
    self.class.files.select do |path|
      path.split('/').last == @name + self.class.file_extension
    end.first
  end

  def containers
    parser = Slices::ContainerParser.new(path)
    parser.parse
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
slices-2.0.2 app/models/layout.rb
slices-2.0.1 app/models/layout.rb
slices-2.0.0 app/models/layout.rb
slices-1.0.5 app/models/layout.rb