Class: Parade::Commands::HtmlOutput

Inherits:
Object
  • Object
show all
Includes:
RenderFromTemplate
Defined in:
lib/parade/commands/html_output.rb

Overview

HtmlOuput creates an HTML representation of the presentation and returns it from the generate method. This is to be consumed by other commands that my use this output to be saved or manipulated.

See Also:

Instance Method Summary collapse

Methods included from RenderFromTemplate

#create_file_with_contents, #default_template_path, #default_view_path, #render_template

Instance Method Details

#descriptionObject



17
18
19
# File 'lib/parade/commands/html_output.rb', line 17

def description
  "This method returns HTML output"
end

#generate(options) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/parade/commands/html_output.rb', line 21

def generate(options)
  filepath = options['filepath']

  return unless File.exists? filepath

  if File.directory? filepath
    root_path = filepath
    root_node = Parsers::PresentationDirectoryParser.parse filepath, :root_path => ".",
      :parade_file => (Array(options['parade_file']) + [ "parade" ]).compact.uniq
  else
    root_path = File.dirname filepath
    root_node = Parsers::PresentationFileParser.parse filepath, :root_path => root_path
  end

  root_node.add_post_renderer Renderers::InlineImages

  template_options = {  'erb_template_file' => File.join(default_view_path, "#{options['template']}.erb"),
                        'custom_asset_path' => root_path,
                        'presentation' => root_node,
                        'slides' => root_node.to_html }

  render_template template_options
end