Sha256: ae45220895e7e62ca01a9177362622a108116dca255cac7ae81ca63705b178d8

Contents?: true

Size: 827 Bytes

Versions: 2

Compression:

Stored size: 827 Bytes

Contents

require_relative "../gadgets"
require_relative "../assembler"

module Marko
  module Services

    # Compitation service
    class Compile < Service
      def initialize(tree: nil, template: '', filename: '', &block)
        @tree = MustbeTreeNode.(tree) if tree
        @template = MustbeString.(template)
        @filename = MustbeString.(filename)
        @block = block

        art = Marko.artifact
        @template = art.template if @template.empty?
        @filename = art.filename if @filename.empty?
      end

      def call
        storage = StoragePlug.plugged
        compiler = CompilerPlug.plugged
        erb = storage.content(@template)
        @tree = Assembler.(&@block) unless @tree
        compiler.(@tree, erb, @filename, &@block) # => filename
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
marko-0.3.0 lib/marko/services/compile.rb
marko-0.1.0 lib/marko/services/compile.rb