Class: Moonrope::DocServer::Generator
- Inherits:
-
Object
- Object
- Moonrope::DocServer::Generator
- Defined in:
- lib/moonrope/doc_server.rb
Instance Attribute Summary collapse
-
#base ⇒ Object
readonly
Returns the value of attribute base.
Instance Method Summary collapse
- #generate_file(output_file, template_file, variables = {}) ⇒ Object
- #host ⇒ Object
-
#initialize(base, options = {}) ⇒ Generator
constructor
A new instance of Generator.
- #prefix ⇒ Object
- #template_root_path ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize(base, options = {}) ⇒ Generator
Returns a new instance of Generator.
32 33 34 35 |
# File 'lib/moonrope/doc_server.rb', line 32 def initialize(base, = {}) @base = base @options = end |
Instance Attribute Details
#base ⇒ Object (readonly)
Returns the value of attribute base.
37 38 39 |
# File 'lib/moonrope/doc_server.rb', line 37 def base @base end |
Instance Method Details
#generate_file(output_file, template_file, variables = {}) ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/moonrope/doc_server.rb', line 55 def generate_file(output_file, template_file, variables = {}) # Generate the page for the requested template with the given variables file = DocContext.new(self, :output_file => output_file, :vars => variables) file_string = file.render(File.join(template_root_path, "#{template_file}.erb")) # Generate the final page within the layout DocContext.new(self, :output_file => output_file, :vars => {:page_title => file.vars[:page_title], :active_nav =>file.vars[:active_nav], :body => file_string}).render(File.join(template_root_path, "layout.erb")) end |
#host ⇒ Object
43 44 45 |
# File 'lib/moonrope/doc_server.rb', line 43 def host @options[:host] end |
#prefix ⇒ Object
47 48 49 |
# File 'lib/moonrope/doc_server.rb', line 47 def prefix @options[:prefix] end |
#template_root_path ⇒ Object
39 40 41 |
# File 'lib/moonrope/doc_server.rb', line 39 def template_root_path File.("../../../templates/basic", __FILE__) end |
#version ⇒ Object
51 52 53 |
# File 'lib/moonrope/doc_server.rb', line 51 def version @options[:version] end |