Module: Webgen::Tag::IncludeFile
- Defined in:
- lib/webgen/tag/include_file.rb
Overview
Includes a file verbatim and optionally escapes all special HTML characters and/or processes webgen tags in it.
Class Method Summary collapse
-
.call(tag, _body, context) ⇒ Object
Include the specified file verbatim in the output, optionally escaping special HTML characters and/or processing tags in it.
Class Method Details
.call(tag, _body, context) ⇒ Object
Include the specified file verbatim in the output, optionally escaping special HTML characters and/or processing tags in it.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/webgen/tag/include_file.rb', line 14 def self.call(tag, _body, context) filename = context[:config]['tag.include_file.filename'] filename = File.join(context.website.directory, filename) unless filename =~ /^(\/|\w:)/ if !File.exist?(filename) raise Webgen::RenderError.new("File '#{filename}' cannot be included because it does not exist", "tag.#{tag}", context.dest_node, context.ref_node) end content = File.read(filename) content = CGI::escapeHTML(content) if context[:config]['tag.include_file.escape_html'] context.website.ext.item_tracker.add(context.dest_node, :file, filename) [content, context[:config]['tag.include_file.process_output']] end |