class Asciidoctor::AbstractNode
def read_asset path, opts = {}
Returns the [String] content of the file at the specified path, or nil
are normalized and coerced to UTF-8 (default: false)
* :normalize a Boolean that controls whether the lines
is issued if the file cannot be read (default: false)
* :warn_on_failure a Boolean that controls whether a warning
opts - a Hash of options to control processing (default: {})
path - the String path from which to read the contents
that the file is readable before attempting to read it.
This method assumes that the path is safe to read. It checks
Public: Read the contents of the file at the specified path.
def read_asset path, opts = {} # remap opts for backwards compatibility opts = { warn_on_failure: (opts != false) } unless ::Hash === opts if ::File.readable? path # QUESTION should we chomp content if normalize is false? opts[:normalize] ? ((Helpers.prepare_source_string ::File.read path, mode: FILE_READ_MODE).join LF) : (::File.read path, mode: FILE_READ_MODE) elsif opts[:warn_on_failure] logger.warn %(#{(attr 'docfile') || '<stdin>'}: #{opts[:label] || 'file'} does not exist or cannot be read: #{path}) nil end end