Include (Class)

In: app/models/chunks/include.rb
Parent: WikiChunk::WikiLink

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.


mask   new   pattern   unmask  


page_name  [R] 

Public Class methods


    # File app/models/chunks/include.rb, line 14
14:   def initialize(match_data)
15:     super(match_data)
16:     @page_name = match_data[1].strip
17:   end


    # File app/models/chunks/include.rb, line 10
10:   def self.pattern() /^\[\[!include(.*)\]\]\s*$/i end

Public Instance methods

This replaces the [[!include PageName]] text with the contents of PageName if it exists. Otherwise a warning is displayed.


    # File app/models/chunks/include.rb, line 22
22:   def mask(content) 
23:     page = content.web.pages[page_name]
24:     (page ? page.content : "<em>Could not include #{page_name}</em>")
25:   end

Keep this chunk regardless of what happens.


    # File app/models/chunks/include.rb, line 28
28:   def unmask(content) self end