Sha256: 7faf5281db0db92e1ec3d7365887c46b7ce982506e3e7a6848f437a46a6beed0

Contents?: true

Size: 771 Bytes

Versions: 1

Compression:

Stored size: 771 Bytes

Contents

# frozen_string_literal: true

require "erb"
require_relative "../compiler"
require_relative "../config"

module Marko
  module Markup

    class Compiler < Marko::Compiler

      # @see Marko::Compliler#call
      def call(tree, template, filename, &block)
        super(tree, template, filename, &block)
        compile
      end

      protected

      def compile
        storage = StoragePlug.plugged
        erbgen = ERB.new(@template, trim_mode: '-')
        payload = @tree.map{|n| Decorator.new(n)}
        storage.write(@filename){|f|
          payload.each{|node|
            @node = node
            text = erbgen.result(binding)
            f.puts text
          }
        }
        @filename
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
marko-0.1.0 lib/marko/markup/compiler.rb