Sha256: fccb04c0b3400bcd8b6cacb1ad43b0fc02ebdee380225f25ac07de08031e727c

Contents?: true

Size: 757 Bytes

Versions: 3

Compression:

Stored size: 757 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

3 entries across 3 versions & 1 rubygems

Version Path
malt-0.4.0 lib/malt/formats/yaml.rb
malt-0.3.0 lib/malt/formats/yaml.rb
malt-0.2.0 lib/malt/formats/yaml.rb