Sha256: a785745c3f9411275624d78a9866304c4ce219318991761c1acab66ab6e58a11

Contents?: true

Size: 751 Bytes

Versions: 1

Compression:

Stored size: 751 Bytes

Contents

require 'malt/formats/abstract'
require 'malt/formats/html'

module Malt::Format

  # = YAML format
  #
  # TODO: hmm... maybe use data to update yaml?
  class YAML < Abstract

    register 'yaml', 'yml'

    #
    def yaml(*)
      text
    end

    alias_method :yml, :yaml

    #
    def to_yaml(*)
      self
    end

    alias_method :to_yml, :to_yaml

    # Converting a plan YAML file to HTML makes no sense so we
    # just wrap it in +pre+ tags.
    def html
      "<pre>\n#{h text}\n</pre>"
    end

    #
    def to_html
      text = html
      opts = options.merge(:text=>text, :file=>refile(:html), :type=>:html)
      HTML.new(opts)
    end

    private

      # TODO: HTML escaping
      def h(text)
        text
      end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
malt-0.1.1 lib/malt/formats/yaml.rb