Sha256: 6823300a65988c1ddbc528d89c447c5918fd54b4588b6f33cdbc2b5e21555c1b
Contents?: true
Size: 1.21 KB
Versions: 1
Compression:
Stored size: 1.21 KB
Contents
require 'webgen/websiteaccess' require 'webgen/tag' require 'cgi' module Webgen::Tag # Includes a file verbatim and optionally escapes all special HTML characters and processes webgen # tags in it. class IncludeFile include Webgen::Tag::Base include Webgen::WebsiteAccess def initialize #:nodoc: website.blackboard.add_listener(:node_changed?, method(:node_changed?)) end # Include the specified file verbatim in the output, optionally escaping special HTML characters # and processing tags in it. def call(tag, body, context) filename = param('tag.includefile.filename') filename = File.join(website.directory, filename) unless filename =~ /^(\/|\w:)/ content = File.read(filename) 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 ####### def node_changed?(node) if filenames = node.node_info[:tag_includefile_filenames] node.dirty = true if filenames.any? {|f, mtime| File.mtime(f) > mtime} end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
webgen-0.5.1 | lib/webgen/tag/includefile.rb |