Sha256: 09da3a5ff85e6daede2ac88ad2dcd9789944ecbdaaf05555d766ee960054b7d7

Contents?: true

Size: 752 Bytes

Versions: 1

Compression:

Stored size: 752 Bytes

Contents

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

module Malt::Formats

  # = 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.0 lib/malt/formats/yaml.rb