mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-20 03:10:39 -07:00
Force user to require the profiler themselves
This commit is contained in:
@@ -73,5 +73,3 @@ require 'liquid/token'
|
|||||||
# Load all the tags of the standard library
|
# Load all the tags of the standard library
|
||||||
#
|
#
|
||||||
Dir[File.dirname(__FILE__) + '/liquid/tags/*.rb'].each { |f| require f }
|
Dir[File.dirname(__FILE__) + '/liquid/tags/*.rb'].each { |f| require f }
|
||||||
|
|
||||||
require 'liquid/profiler'
|
|
||||||
|
|||||||
+5
-12
@@ -1,9 +1,12 @@
|
|||||||
|
require 'liquid/profiler/hooks'
|
||||||
|
|
||||||
module Liquid
|
module Liquid
|
||||||
|
|
||||||
# Profiler enables support for profiling template rendering to help track down performance issues.
|
# Profiler enables support for profiling template rendering to help track down performance issues.
|
||||||
#
|
#
|
||||||
# To enable profiling, pass the <tt>profile: true</tt> option to <tt>Liquid::Template.parse</tt>. Then, after
|
# To enable profiling, first require 'liquid/profiler'.
|
||||||
# <tt>Liquid::Template#render</tt> is called, the template object makes available an instance of this
|
# Then, to profile a parse/render cycle, pass the <tt>profile: true</tt> option to <tt>Liquid::Template.parse</tt>.
|
||||||
|
# After <tt>Liquid::Template#render</tt> is called, the template object makes available an instance of this
|
||||||
# class via the <tt>Liquid::Template#profiler</tt> method.
|
# class via the <tt>Liquid::Template#profiler</tt> method.
|
||||||
#
|
#
|
||||||
# template = Liquid::Template.parse(template_content, profile: true)
|
# template = Liquid::Template.parse(template_content, profile: true)
|
||||||
@@ -70,16 +73,6 @@ module Liquid
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.hooks_loaded
|
|
||||||
@hooks_loaded
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.load_hooks
|
|
||||||
return if @hooks_loaded
|
|
||||||
require 'liquid/profiler/hooks'
|
|
||||||
@hooks_loaded = true
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.profile_token_render(token)
|
def self.profile_token_render(token)
|
||||||
if Profiler.current_profile && token.respond_to?(:render)
|
if Profiler.current_profile && token.respond_to?(:render)
|
||||||
Profiler.current_profile.start_token(token)
|
Profiler.current_profile.start_token(token)
|
||||||
|
|||||||
@@ -250,7 +250,7 @@ module Liquid
|
|||||||
|
|
||||||
def with_profiling
|
def with_profiling
|
||||||
if @profiling && !@options[:included]
|
if @profiling && !@options[:included]
|
||||||
raise "Profiler hooks not loaded, call Liquid::Profiler.load_hooks first" unless Profiler.hooks_loaded
|
raise "Profiler not loaded, require 'liquid/profiler' first" unless defined?(Profiler)
|
||||||
|
|
||||||
@profiler = Profiler.new
|
@profiler = Profiler.new
|
||||||
@profiler.start
|
@profiler.start
|
||||||
|
|||||||
+1
-1
@@ -5,6 +5,7 @@ require 'spy/integration'
|
|||||||
|
|
||||||
$:.unshift(File.join(File.expand_path(File.dirname(__FILE__)), '..', 'lib'))
|
$:.unshift(File.join(File.expand_path(File.dirname(__FILE__)), '..', 'lib'))
|
||||||
require 'liquid.rb'
|
require 'liquid.rb'
|
||||||
|
require 'liquid/profiler'
|
||||||
|
|
||||||
mode = :strict
|
mode = :strict
|
||||||
if env_mode = ENV['LIQUID_PARSER_MODE']
|
if env_mode = ENV['LIQUID_PARSER_MODE']
|
||||||
@@ -12,7 +13,6 @@ 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