Parent

Class/Module Index [+]

Quicksearch

Webgen::Tag::IncludeFile

Includes a file verbatim and optionally escapes all special HTML characters and processes webgen tags in it.

Public Instance Methods

call(tag, body, context) click to toggle source

Include the specified file verbatim in the output, optionally escaping special HTML characters and processing tags in it.

# File lib/webgen/tag/includefile.rb, line 19
def call(tag, body, context)
  filename = param('tag.includefile.filename')
  filename = File.join(website.directory, filename) unless filename =~ /^(\/|\w:)/
  content = File.open(filename, 'rb') {|f| f.read}
  content = CGI::escapeHTML(content) if param('tag.includefile.escape_html')
  (context.dest_node.node_info[:tag_includefile_filenames] ||= []) << [filename, File.mtime(filename)]

  [content, param('tag.includefile.process_output')]
end

Private Instance Methods

node_changed?(node) click to toggle source
# File lib/webgen/tag/includefile.rb, line 33
def node_changed?(node)
  if filenames = node.node_info[:tag_includefile_filenames]
    node.flag(:dirty) if filenames.any? {|f, mtime| File.mtime(f) > mtime}
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.