Sha256: 8e3f60ad1c3e56004e011ecbce917d207f16fc6d9ff7b389b2665dafd5eafab6

Contents?: true

Size: 752 Bytes

Versions: 30

Compression:

Stored size: 752 Bytes

Contents

require 'jsduck/util/null_object'
require 'jsduck/util/io'

module JsDuck

  class Welcome
    # Creates Welcome object from filename.
    def self.create(filename, doc_formatter)
      if filename
        Welcome.new(filename, doc_formatter)
      else
        Util::NullObject.new(:to_html => "")
      end
    end

    # Parses welcome HTML or Markdown file with content for welcome page.
    def initialize(filename, doc_formatter)
      @html = Util::IO.read(filename)
      if filename =~ /\.(md|markdown)\z/i
        @html = '<div class="markdown">' + doc_formatter.format(@html) + '</div>'
      end
    end

    # Returns the HTML
    def to_html(style="")
      "<div id='welcome-content' style='#{style}'>#{@html}</div>"
    end

  end

end

Version data entries

30 entries across 30 versions & 3 rubygems

Version Path
solvas-jsduck-6.0.0.30539 lib/jsduck/welcome.rb
solvas-jsduck-6.0.0.9571 lib/jsduck/welcome.rb
solvas-jsduck-6.0.0.6154 lib/jsduck/welcome.rb
solvas-jsduck-6.0.0.4021 lib/jsduck/welcome.rb
solvas-jsduck-6.0.0.2554 lib/jsduck/welcome.rb
solvas-jsduck-6.0.0.1891 lib/jsduck/welcome.rb
solvas-jsduck-6.0.0.beta.1888 lib/jsduck/welcome.rb
jsduck-troopjs-0.0.10 lib/jsduck/welcome.rb
jsduck-troopjs-0.0.9 lib/jsduck/welcome.rb
jsduck-troopjs-0.0.8 lib/jsduck/welcome.rb
jsduck-troopjs-0.0.7 lib/jsduck/welcome.rb
jsduck-troopjs-0.0.5 lib/jsduck/welcome.rb
jsduck-troopjs-0.0.4 lib/jsduck/welcome.rb
jsduck-troopjs-0.0.3 lib/jsduck/welcome.rb
jsduck-troopjs-0.0.1 lib/jsduck/welcome.rb
jsduck-6.0.0beta lib/jsduck/welcome.rb
jsduck-5.3.4 lib/jsduck/welcome.rb
jsduck-5.3.3 lib/jsduck/welcome.rb
jsduck-5.3.2 lib/jsduck/welcome.rb
jsduck-5.3.1 lib/jsduck/welcome.rb