@param [String] content  source code of the template
 @param [String] file_path  reference path to template file

 @return [Bade::AST::Document]
517960
def _parsed_document(content, file_path)
      if file_path.nil? && content.nil?
        raise LoadError.new(nil, file_path, "Don't know what to do with nil values for both content and path")
      end

      content = if !file_path.nil? && content.nil?
                  File.read(file_path)
                else
                  content
                end

      parsed_document = parsed_documents[file_path]
      return parsed_document unless parsed_document.nil?

      parser = Parser.new(file_path: file_path)
      document = parser.parse(content)

      parser.dependency_paths.each do |path|
        new_path = _find_file!(path, file_path)
        next if new_path.nil?

        document.sub_documents << _parsed_document(nil, new_path)
      end

      document
    end
1029185
def parse_file_content(file_path)
      text = ::File.read(file_path)
      tokens = text.split(%r{^\[(.*?)\]\r?\n})
      tokens.shift # first item should be blank
      tokens.in_groups_of(2).each_with_object({}) do |pair, h|
        h[pair[0]] = pair[1]
      end
    end
49341
def fetch_file_contents(remote_path)
      result = backend.file(remote_path)
      if result.exist? && result.file?
        result.content
      else
        nil
      end
    end
809597
def snippet_path(path = nil)
      if snippet_json["main"].nil?
        real_path path
      else
        real_path ::File.join(snippet_json["main"], path)
      end
    end
1260936
def get_compiled_file_content(path)
      begin
        Tilt.new(path.to_s).render({}, {
          :spec => spec
        })
      rescue RuntimeError
        File.read(path)
      end
    end
1367551
def extract_path(file_path)
      return nil if file_path.nil?
      last_slash = file_path.rindex("/")
      if last_slash
        file_path[0, last_slash]
      end
    end
717982
def file_write(filepath, newcontent, backup=false)
      if self.file_exists?(filepath)
        self.cp filepath, "#{filepath}-previous" if backup
      end
      
      content = StringIO.new
      content.puts newcontent
      self.file_upload content, filepath
    end
1215682
def goto(file_path)
      html = File.read(file_path)
      @driver = Nokogiri::HTML.parse(html)
    end
372693
def in_noninjected_file(self, file_path, content):
        
        if os.path.exists(file_path):
            file_content = codecs.open(file_path, encoding="utf-8").read()
            file_content = self.wrapper_match.sub(u"", file_content)
        else:
            file_content = ""
        return file_content.find(content) != -1
365620
def handle_xhtml_file(file_path)
      html_doc = Nokogiri::XML(File.open(file_path))

      add_file_to_head(:js, html_doc, 'vendor/bower/jquery/jquery.min.js')
      add_file_to_head(:js, html_doc, 'vendor/bower/spin/spin.js')
      add_file_to_head(:js, html_doc, 'vendor/bower/cookies/cookies.min.js')
      add_file_to_head(:js, html_doc, 'vendor/bower/uri/URI.min.js')
      add_file_to_head(:js, html_doc, 'vendor/bower/keymaster/keymaster.js')
      add_file_to_head(:style, html_doc, 'book_content.styl')

      add_file_to_head(:js, html_doc, 'support.coffee')
      add_meta_to_head(:viewport, 'width=device-width, initial-scale=1.0', html_doc)
      add_auto_refresh_script(html_doc)

      unless file_resolver.nil?
        current_index = file_resolver.spine_files.index { |file| file.final_destination_path == file_path }

        unless current_index.nil?
          previous_path = spine_file_at(current_index - 1).try(:pkg_destination_path)
          next_path     = spine_file_at(current_index + 1).try(:pkg_destination_path)
          add_keyboard_control_script(html_doc, previous_path, next_path)
        end
      end

      [200, html_doc.to_xhtml]
    end
1132776
def contents(custom_binding = nil)
      return @contents unless @contents.nil?

      @contents = File.read(path)
      if path.extname == '.erb'
        @contents = ERB.new(@contents, nil, '>').result(custom_binding ? custom_binding : binding)
      end
      @contents
    end
730612
def process_file(path)
      code      = File.read(path)
      sexp_node = RubyParser.new.parse(code)
      file      = Mago::RubyFile.new(path)

      sexp_processor = Mago::SexpProcessor.new(file, @ignore)
      sexp_processor.process(sexp_node)

      @report.files << file
      @on_file.call(file) if @on_file
    rescue Errno::ENOENT => err
      handle_error(err.message)
    rescue Racc::ParseError, Encoding::CompatibilityError => err
      msg = "#{path} has invalid ruby code. " << err.message
      handle_error(msg)
    end
1055349
def file(name, &block)
      path = @path + name
      unless ::File.file?(path)
        FileUtils.touch(path)
        @ctx.add(path)
      end
      f = File.new(@ctx, path)
      f.instance_eval(&block) if block_given?
      f
    end
1345935
def content

      # Handle case where user passes the full path
      #
      file = @options['template'] || default_template

      if file
        file.sub!(/^_templates\//, '')
        file = File.join(site.source, '_templates', file) if file
        if File.exist? file
          parse_template File.open(file).read.encode('UTF-8')
        elsif @options['template']
          abort "No #{@options['type']} template found at #{file}"
        else
          parse_template default_front_matter
        end
      else
        parse_template default_front_matter
      end
    end
682585
private void buildTemplatedMetadataFile(String path) throws IOException {
    try (InputStream is = getClass().getResourceAsStream("/content-package-template/" + path)) {
      String xmlContent = IOUtils.toString(is);
      for (Map.Entry<String, Object> entry : metadata.getVars().entrySet()) {
        xmlContent = StringUtils.replace(xmlContent, "{{" + entry.getKey() + "}}",
            StringEscapeUtils.escapeXml10(entry.getValue().toString()));
      }
      zip.putNextEntry(new ZipEntry(path));
      try {
        zip.write(xmlContent.getBytes(Charsets.UTF_8));
      }
      finally {
        zip.closeEntry();
      }
    }
  }
1252457
def create_template
        if File.directory?(FileUtils.join_paths(JumpStart.templates_path, @template_name))
          puts "\nThe directory #{FileUtils.join_paths(JumpStart.templates_path, @template_name).red} already exists. The template will not be created."
          exit_normal
        else
          FileUtils.mkdir_p(FileUtils.join_paths(JumpStart.templates_path, @template_name, "/jumpstart_config"))
          yaml = IO.read(FileUtils.join_paths(ROOT_PATH, "/source_templates/template_config.yml"))
          File.open(FileUtils.join_paths(JumpStart.templates_path, @template_name, "/jumpstart_config", "#{@template_name}.yml"), 'w') do |file|
            file.puts yaml
          end
          puts "The template #{@template_name.green} has been generated.\n"
        end
      end
940283
def _get_file_content(source):
    
    filepath = os.path.join('siglists', source + '.txt')

    lines = []
    with resource_stream(__name__, filepath) as f:
        for i, line in enumerate(f):
            line = line.decode('utf-8', 'strict').strip()
            if not line or line.startswith('#'):
                continue

            try:
                re.compile(line)
            except Exception as ex:
                raise BadRegularExpressionLineError(
                    'Regex error: {} in file {} at line {}'.format(
                        str(ex),
                        filepath,
                        i
                    )
                )

            lines.append(line)

    if source in _SPECIAL_EXTENDED_VALUES:
        lines = lines + _SPECIAL_EXTENDED_VALUES[source]

    return tuple(lines)