Sha256: f02ba64365ed8f11bdf66e596d1449290c7784138d919e79671d033914eae134

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

Contents

require 'wlang/dialect/dispatching'
require 'wlang/dialect/evaluation'
require 'wlang/dialect/tags'
module WLang
  class Dialect
    include Dialect::Dispatching
    include Dialect::Evaluation
    include Dialect::Tags

    class << self

      def factor(options = {})
        new(default_options.merge(options))
      end

      def default_options(options = {})
        @default_options ||= (superclass.default_options.dup rescue {})
        @default_options.merge!(options)
      end

      def compiler(options = {})
        factor(options).compiler
      end

      def compile(source, options = {})
        compiler(options).compile(source)
      end

      def to_ruby_code(source, options = {})
        compiler(options).to_ruby_code(source)
      end

      def render(source, scope = {}, buffer = "")
        compile(source).call(scope, buffer)
      end

    end

    default_options :braces      => WLang::BRACES,
                    :autospacing => false

    attr_reader :options
    def braces; options[:braces]; end

    attr_reader :compiler

    def initialize(options = {})
      @options  = options
      @compiler = WLang::Compiler.new(self)
    end

  end # class Dialect
end # module WLang

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wlang-2.0.0.beta lib/wlang/dialect.rb