Sha256: 5fcb24467c4c50f75d5d892244168a3471492a29efa043a31ec95cbbc7f7630d

Contents?: true

Size: 534 Bytes

Versions: 6

Compression:

Stored size: 534 Bytes

Contents

module Hamlit
  class Compiler
    class SilentScriptCompiler
      def compile(node, &block)
        if node.children.empty?
          [:multi, [:code, node.value[:text]], [:newline]]
        else
          compile_with_children(node, &block)
        end
      end

      private

      def compile_with_children(node, &block)
        temple = [:multi]
        temple << [:code, node.value[:text]]
        temple << [:newline]
        temple << yield(node)
        temple << [:code, 'end']
        temple
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
hamlit-2.2.0 lib/hamlit/compiler/silent_script_compiler.rb
hamlit-2.1.2 lib/hamlit/compiler/silent_script_compiler.rb
hamlit-2.1.1 lib/hamlit/compiler/silent_script_compiler.rb
hamlit-2.1.0 lib/hamlit/compiler/silent_script_compiler.rb
hamlit-2.0.2 lib/hamlit/compiler/silent_script_compiler.rb
hamlit-2.0.1 lib/hamlit/compiler/silent_script_compiler.rb