lib/nanoc/base/compilation/compiler.rb
def route_reps
      reps.each do |rep|
        # Find matching rules
        rules = rules_collection.routing_rules_for(rep)
        raise Nanoc::Errors::NoMatchingRoutingRuleFound.new(rep) if rules[:last].nil?

        rules.each_pair do |snapshot, rule|
          # Get basic path by applying matching rule
          basic_path = rule.apply_to(rep, :compiler => self)
          next if basic_path.nil?
          if basic_path !~ %r{^/}
            raise RuntimeError, "The path returned for the #{rep.inspect} item representation, “#{basic_path}”, does not start with a slash. Please ensure that all routing rules return a path that starts with a slash."
          end

          # Get raw path by prepending output directory
          rep.raw_paths[snapshot] = @site.config[:output_dir] + basic_path

          # Get normal path by stripping index filename
          rep.paths[snapshot] = basic_path
          @site.config[:index_filenames].each do |index_filename|
            if rep.paths[snapshot][-index_filename.length..-1] == index_filename
              # Strip and stop
              rep.paths[snapshot] = rep.paths[snapshot][0..-index_filename.length-1]
              break
            end
          end
        end
      end
    end
# Determines the paths of all item representations.
#
# @api private
Determines the paths of all item representations.
Determines the paths of all item representations .
def route_reps
      reps.each do |rep|
        rules = rules_collection.routing_rules_for(rep)
        raise Nanoc::Errors::NoMatchingRoutingRuleFound.new(rep) if rules[:last].nil?
        rules.each_pair do |snapshot, rule|
          basic_path = rule.apply_to(rep, :compiler => self)
          next if basic_path.nil?
          if basic_path !~ %r{^/}
            raise RuntimeError, "The path returned for the #{rep.inspect} item representation, “#{basic_path}”, does not start with a slash. Please ensure that all routing rules return a path that starts with a slash."
          end
          rep.raw_paths[snapshot] = @site.config[:output_dir] + basic_path
          rep.paths[snapshot] = basic_path
          @site.config[:index_filenames].each do |index_filename|
            if rep.paths[snapshot][-index_filename.length..-1] == index_filename
              rep.paths[snapshot] = rep.paths[snapshot][0..-index_filename.length-1]
              break
            end
          end
        end
      end
    end
def route_reps reps . each do | rep | rules = rules_collection . routing_rules_for ( rep ) raise Nanoc :: Errors :: NoMatchingRoutingRuleFound . new ( rep ) if rules [ :last ] . nil? rules . each_pair do | snapshot , rule | basic_path = rule . apply_to ( rep , :compiler => self ) next if basic_path . nil? if basic_path !~ %r{ ^/ } raise RuntimeError , "The path returned for the #{rep.inspect} item representation, “#{basic_path}”, does not start with a slash. Please ensure that all routing rules return a path that starts with a slash." end rep . raw_paths [ snapshot ] = @site . config [ :output_dir ] + basic_path rep . paths [ snapshot ] = basic_path @site . config [ :index_filenames ] . each do | index_filename | if rep . paths [ snapshot ] [ - index_filename . length .. - 1 ] == index_filename rep . paths [ snapshot ] = rep . paths [ snapshot ] [ 0 .. - index_filename . length - 1 ] break end end end end end
Determines the paths of all item representations.
Determines the paths of all item representations .
# Find matching rules # Get basic path by applying matching rule # Get raw path by prepending output directory # Get normal path by stripping index filename # Strip and stop
api
None