mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-29 15:15:19 -07:00
Don't automatically load hooks
This commit is contained in:
@@ -41,10 +41,6 @@ module Liquid
|
|||||||
|
|
||||||
singleton_class.send(:attr_accessor, :cache_classes)
|
singleton_class.send(:attr_accessor, :cache_classes)
|
||||||
self.cache_classes = true
|
self.cache_classes = true
|
||||||
|
|
||||||
def self.load_profiler_hooks
|
|
||||||
require 'liquid/profiler/hooks'
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
require "liquid/version"
|
require "liquid/version"
|
||||||
|
|||||||
@@ -71,7 +71,13 @@ module Liquid
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.hooks_loaded
|
def self.hooks_loaded
|
||||||
false
|
@hooks_loaded
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.load_hooks
|
||||||
|
return if @hooks_loaded
|
||||||
|
require 'liquid/profiler/hooks'
|
||||||
|
@hooks_loaded = true
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.profile_token_render(token)
|
def self.profile_token_render(token)
|
||||||
|
|||||||
@@ -1,10 +1,4 @@
|
|||||||
module Liquid
|
module Liquid
|
||||||
class Profiler
|
|
||||||
def self.hooks_loaded
|
|
||||||
true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
class BlockBody
|
class BlockBody
|
||||||
def render_token_with_profiling(token, context)
|
def render_token_with_profiling(token, context)
|
||||||
Profiler.profile_token_render(token) do
|
Profiler.profile_token_render(token) do
|
||||||
|
|||||||
@@ -250,7 +250,7 @@ module Liquid
|
|||||||
|
|
||||||
def with_profiling
|
def with_profiling
|
||||||
if @profiling && !@options[:included]
|
if @profiling && !@options[:included]
|
||||||
Liquid.load_profiler_hooks unless Profiler.hooks_loaded
|
raise "Profiler hooks not loaded, call Liquid::Profiler.load_hooks first" unless Profiler.hooks_loaded
|
||||||
|
|
||||||
@profiler = Profiler.new
|
@profiler = Profiler.new
|
||||||
@profiler.start
|
@profiler.start
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ if env_mode = ENV['LIQUID_PARSER_MODE']
|
|||||||
mode = env_mode.to_sym
|
mode = env_mode.to_sym
|
||||||
end
|
end
|
||||||
Liquid::Template.error_mode = mode
|
Liquid::Template.error_mode = mode
|
||||||
|
Liquid::Profiler.load_hooks
|
||||||
|
|
||||||
if Minitest.const_defined?('Test')
|
if Minitest.const_defined?('Test')
|
||||||
# We're on Minitest 5+. Nothing to do here.
|
# We're on Minitest 5+. Nothing to do here.
|
||||||
|
|||||||
Reference in New Issue
Block a user