lib/locomotive/mounter/reader/file_system/pages_reader.rb
# Add a new page in the global hash of pages.
# If the page exists, override it.
#
# @param [ String ] filepath The path of the template
# @param [ Hash ] attributes The attributes of the new page
#
# @return [ Object ] A newly created page or the existing one
#
Add a new page in the global hash of pages.
If the page exists, override it.
Add a new page in the global hash of pages . If the page exists override it .
def add(filepath, attributes = {})
            fullpath = self.filepath_to_fullpath(filepath)
            unless self.pages.key?(fullpath)
              attributes[:title]    = File.basename(fullpath).humanize
              attributes[:fullpath] = attributes[:_fullpath] = fullpath
              page = Locomotive::Mounter::Models::Page.new(attributes)
              page.mounting_point = self.mounting_point
              page.filepath       = File.expand_path(filepath)
              page.template = OpenStruct.new(raw_source: '') if File.directory?(filepath)
              self.pages[fullpath] = page
            end
            self.pages[fullpath]
          end
def add ( filepath , attributes = { } ) fullpath = self . filepath_to_fullpath ( filepath ) unless self . pages . key? ( fullpath ) attributes [ :title ] = File . basename ( fullpath ) . humanize attributes [ :fullpath ] = attributes [ :_fullpath ] = fullpath page = Locomotive :: Mounter :: Models :: Page . new ( attributes ) page . mounting_point = self . mounting_point page . filepath = File . expand_path ( filepath ) page . template = OpenStruct . new ( raw_source : '' ) if File . directory? ( filepath ) self . pages [ fullpath ] = page end self . pages [ fullpath ] end
Add a new page in the global hash of pages.
Add a new page in the global hash of pages .
A newly created page or the existing one
A newly created page or the existing one
 Object 
filepath
<not_specific>
attributes
<not_specific>
<not_specific>
attributes The attributes of the new page
attributes The attributes of the new page