Sha256: 9e4dc65a96d85dc9f02f2c142731342c01d63eea8277295fbe4e184d922421da

Contents?: true

Size: 1.36 KB

Versions: 6

Compression:

Stored size: 1.36 KB

Contents

require_relative '../renderers/inline_images'

module Parade
  module Commands

    #
    # 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 StaticHtml
    # @see StaticPdf
    #
    class HtmlOutput
      include RenderFromTemplate

      def description
        "This method returns HTML output"
      end

      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", "parade.json" ]).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,
                              'slides' => root_node.to_html }

        render_template template_options
      end

    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
parade-0.9.2 lib/parade/commands/html_output.rb
parade-0.9.1 lib/parade/commands/html_output.rb
parade-0.9.0 lib/parade/commands/html_output.rb
parade-0.8.2 lib/parade/commands/html_output.rb
parade-0.8.1 lib/parade/commands/html_output.rb
parade-0.8.0 lib/parade/commands/html_output.rb