Sha256: dfed9cf5babef92a91c6baa9540a450e4e094f8117f86502058d2fc1f1b46a0d

Contents?: true

Size: 1.07 KB

Versions: 181

Compression:

Stored size: 1.07 KB

Contents

require 'tilt/template'

module Tilt
  # Markaby
  # http://github.com/markaby/markaby
  class MarkabyTemplate < Template
    def self.builder_class
      @builder_class ||= Class.new(Markaby::Builder) do
        def __capture_markaby_tilt__(&block)
          __run_markaby_tilt__ do
            text capture(&block)
          end
        end
      end
    end

    def self.engine_initialized?
      defined? ::Markaby
    end

    def initialize_engine
      require_template_library 'markaby'
    end

    def prepare
    end

    def evaluate(scope, locals, &block)
      builder = self.class.builder_class.new({}, scope)
      builder.locals = locals

      if data.kind_of? Proc
        (class << builder; self end).send(:define_method, :__run_markaby_tilt__, &data)
      else
        builder.instance_eval <<-CODE, __FILE__, __LINE__
          def __run_markaby_tilt__
            #{data}
          end
        CODE
      end

      if block
        builder.__capture_markaby_tilt__(&block)
      else
        builder.__run_markaby_tilt__
      end

      builder.to_s
    end
  end
end

Version data entries

181 entries across 156 versions & 27 rubygems

Version Path
scout_realtime-0.5.3 lib/vendor/tilt-1.4.1/lib/tilt/markaby.rb
scout_realtime-0.5.2 lib/vendor/tilt-1.4.1/lib/tilt/markaby.rb
scout_realtime-0.5.1 lib/vendor/tilt-1.4.1/lib/tilt/markaby.rb
mango-0.8.0 vendor/bundler/ruby/2.1.0/gems/tilt-1.4.1/lib/tilt/markaby.rb
mango-0.7.1 vendor/bundler/ruby/2.0.0/gems/tilt-1.4.1/lib/tilt/markaby.rb
mango-0.7.0 vendor/bundler/ruby/2.0.0/gems/tilt-1.4.1/lib/tilt/markaby.rb
torquebox-console-0.3.0 vendor/bundle/jruby/1.9/gems/tilt-1.3.4/lib/tilt/markaby.rb
challah-1.0.0 vendor/bundle/gems/tilt-1.4.1/lib/tilt/markaby.rb
classiccms-0.7.2 vendor/bundle/gems/tilt-1.3.3/lib/tilt/markaby.rb
classiccms-0.7.1 vendor/bundle/gems/tilt-1.3.3/lib/tilt/markaby.rb
swipe-rails-0.0.5 vendor/bundle/gems/tilt-1.4.1/lib/tilt/markaby.rb
active_mailer-0.0.9 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/tilt-1.3.3/lib/tilt/markaby.rb
active_mailer-0.0.8 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/tilt-1.3.3/lib/tilt/markaby.rb
active_mailer-0.0.7 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/tilt-1.3.3/lib/tilt/markaby.rb
active_mailer-0.0.6 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/tilt-1.3.3/lib/tilt/markaby.rb
classiccms-0.7.0 vendor/bundle/gems/tilt-1.3.3/lib/tilt/markaby.rb
font-awesome-rails-3.1.1.2 vendor/ruby/1.9.1/gems/tilt-1.3.7/lib/tilt/markaby.rb
font-awesome-rails-3.1.1.2 vendor/ruby/2.0.0/gems/tilt-1.3.5/lib/tilt/markaby.rb
font-awesome-rails-3.1.1.2 vendor/ruby/1.9.1/gems/tilt-1.3.5/lib/tilt/markaby.rb
font-awesome-rails-3.1.1.1 vendor/ruby/1.9.1/gems/tilt-1.3.7/lib/tilt/markaby.rb