Sha256: c76d83925a4a9e1e562a1d4efba6ec687d6bb4ad85055ac40f5a9a1781685c86
Contents?: true
Size: 945 Bytes
Versions: 4
Compression:
Stored size: 945 Bytes
Contents
require 'chunks/wiki' # Includes the contents of another page for rendering. # The include command looks like this: "[[!include PageName]]". # It is a WikiLink since it refers to another page (PageName) # and the wiki content using this command must be notified # of changes to that page. # If the included page could not be found, a warning is displayed. class Include < WikiChunk::WikiLink def self.pattern() /^\[\[!include(.*)\]\]\s*$/i end attr_reader :page_name def initialize(match_data, revision) super(match_data, revision) @page_name = match_data[1].strip end # This replaces the [[!include PageName]] text with # the contents of PageName if it exists. Otherwise # a warning is displayed. def mask(content) page = content.web.pages[page_name] (page ? page.content : "<em>Could not include #{page_name}</em>") end # Keep this chunk regardless of what happens. def unmask(content) self end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
Pimki-1.4.092 | app/models/chunks/include.rb |
Pimki-1.5.092 | app/models/chunks/include.rb |
Pimki-1.6.092 | app/models/chunks/include.rb |
Pimki-1.7.092 | app/models/chunks/include.rb |