Class: Brandish::Processors::All::Import

Inherits:
Brandish::Processor::Base show all
Includes:
Brandish::Processor::Command
Defined in:
lib/brandish/processors/all/import.rb

Overview

Note:

Be careful when using :remote_allowed - this can cause possible security issues if the remote is not trusted.

"Imports" another file into this current file. This takes the file, parses it, and inserts it directly into the position that the import was placed. By default, this forces the file to be in the source directory, doing some awkward joining to make it work. This takes one pair - "name", "link", or "file" - which contains the name of the file to import. It takes two options: :absolute_allowed, which allows imports to be outside of the source directory; and :remote_allowed, which allows remote files to be imported, using any of the protocols supported by open-uri.

For local file imports, if no extensions were provided, an extension of .br is automatically added. For remote files, extensions are always required.

Imports are handled as if the entire imported file was copy and pasted into the source document.

Options:

  • :absolute_allowed - Optional. Despite its name, if this value is true, imports can be used with any file that is outside of the source directory. Otherwise, the files will be forced to be inside the source directory, as if the source directory is the root of the file system.
  • :remote_allowed - Optional. Whether remote imports should be allowed.

Pairs:

  • "src", "file", "name", or "link" - Required. These all do the same thing - it provides the name of the file to import.

Examples:

local file

<import file="some-file" />

remote file

<import link="http://example.org/some-file.br" />

absolute local file

<import file="/opt/brandish/sources/html" />

Instance Attribute Summary

Attributes inherited from Brandish::Processor::Base

#context

Instance Method Summary collapse

Methods included from Brandish::Processor::Command

included, #process_command

Methods inherited from Brandish::Processor::Base

#accept, #call, #initialize, #postprocess, #process_block, #process_command, #process_root, #process_text, register, #setup

Constructor Details

This class inherits a constructor from Brandish::Processor::Base

Instance Method Details

#performParser::Node

Accepts the root node of the parsed file, processing the result as if it were an extension of the original source tree.

Returns:



59
60
61
# File 'lib/brandish/processors/all/import.rb', line 59

def perform
  accept(parse_file)
end