lib/tilt.rb in tilt-2.2.0 vs lib/tilt.rb in tilt-2.3.0

- old
+ new

@@ -3,11 +3,11 @@ require_relative 'tilt/template' # Namespace for Tilt. This module is not intended to be included anywhere. module Tilt # Current version. - VERSION = '2.2.0' + VERSION = '2.3.0' EMPTY_HASH = {}.freeze private_constant :EMPTY_HASH @default_mapping = Mapping.new @@ -16,10 +16,12 @@ # mapping. This can be done to improve performance after the template # libraries you desire to use have already been loaded. Once this is # is called, all attempts to modify the default mapping will fail. # This also freezes Tilt itself. def self.finalize! + return self if @default_mapping.is_a?(FinalizedMapping) + class << self prepend(Module.new do def lazy_map(*) raise "Tilt.#{__callee__} not supported after Tilt.finalize! has been called" end @@ -76,22 +78,9 @@ end # @see Tilt::Mapping#templates_for def self.templates_for(file) @default_mapping.templates_for(file) - end - - # @return the template object that is currently rendering. - # - # @example - # tmpl = Tilt['index.erb'].new { '<%= Tilt.current_template %>' } - # tmpl.render == tmpl.to_s - # - # @note This is currently an experimental feature and might return nil - # in the future. - def self.current_template - warn "Tilt.current_template is deprecated and will be removed in Tilt 2.3", uplevel: 1 - Thread.current[:tilt_current_template] end class << self # @return [Tilt::Mapping] the main mapping object attr_reader :default_mapping