Class: ChiliProject::Liquid::FileSystem

Inherits:
Object
  • Object
show all
Defined in:
lib/chili_project/liquid/file_system.rb

Instance Method Summary collapse

Instance Method Details

#read_template_file(template_name, context) ⇒ Object

Raises:

  • (::Liquid::FileSystemError)

18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/chili_project/liquid/file_system.rb', line 18

def read_template_file(template_name, context)
  raise ::Liquid::FileSystemError.new("Page not found") if template_name.blank?
  project = Project.find(context['project'].identifier) if context['project'].present?

  cross_project_page = template_name.include?(':')
  page = Wiki.find_page(template_name.to_s.strip, :project => (cross_project_page ? nil : project))
  if page.nil? || !page.visible?
    raise ::Liquid::FileSystemError.new("No such page '#{template_name}'")
  end

  page.content
end