Sha256: 045ba8212064c409f28d006dd448477d823b0e49f4aa367de11cb1668a791b48

Contents?: true

Size: 1.41 KB

Versions: 1

Compression:

Stored size: 1.41 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" ]).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

    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
parade-0.10.2 lib/parade/commands/html_output.rb