Sha256: 884adfd31fb940daf5370ff99e2e82c1c26876ddc4856af0a250724e46a9d1a6

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 KB

Contents

module Slim
  # Tilt template implementation for Slim
  # @api public
  class Template < Tilt::Template
    # Prepare Slim template
    #
    # Called immediately after template data is loaded.
    #
    # @return [void]
    def prepare
      @src = Engine.new(options.merge(:file => eval_file)).compile(data)
    end

    # Process the template and return the result.
    #
    # Template executationis guaranteed to be performed in the scope object with the locals
    # specified and with support for yielding to the block.
    #
    # @param [Object] scope Scope object where the code is evaluated
    # @param [Hash]   locals Local variables
    # @yield Block given to the template code
    # @return [String] Evaluated template
    def evaluate(scope, locals, &block)
      scope.instance_eval { extend Slim::Helpers } if options[:helpers]
      super
    end

    # A string containing the (Ruby) source code for the template.
    #
    # @param [Hash]   locals Local variables
    # @return [String] Compiled template ruby code
    def precompiled_template(locals)
      @src
    end
  end

  Tilt.register 'slim', Template
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
slim-0.7.0 lib/slim/template.rb