mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
Change template rendering engine
This commit is contained in:
parent
44614b5da2
commit
921031b5ae
2 changed files with 5 additions and 6 deletions
|
@ -106,7 +106,7 @@ module Sidekiq
|
|||
Sidekiq::WebApplication.helpers WebHelpers
|
||||
Sidekiq::WebApplication.helpers Sidekiq::Paginator
|
||||
|
||||
ERB.new(File.read Web::LAYOUT).def_method(WebAction, '_render')
|
||||
Sidekiq::WebAction.class_eval "def _render\n#{ERB.new(File.read(Web::LAYOUT)).src}\nend"
|
||||
end
|
||||
|
||||
if defined?(::ActionDispatch::Request::Session) &&
|
||||
|
|
|
@ -51,9 +51,9 @@ module Sidekiq
|
|||
|
||||
def erb(content, options = {})
|
||||
if content.kind_of? Symbol
|
||||
filename = "#{Web.settings.views}/#{content}.erb"
|
||||
unless content = @@files[filename]
|
||||
content = @@files[filename] = ERB.new(File.read(filename))
|
||||
unless respond_to?(:"_erb_#{content}")
|
||||
src = ERB.new(File.read("#{Web.settings.views}/#{content}.erb")).src
|
||||
WebAction.class_eval("def _erb_#{content}\n#{src}\n end")
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -86,13 +86,12 @@ module Sidekiq
|
|||
private
|
||||
|
||||
def _erb(file, locals)
|
||||
# TODO Use Binding#local_variable_set if/when support for 2.0.0 is dropped
|
||||
locals.each {|k, v| define_singleton_method(k){ v } } if locals
|
||||
|
||||
if file.kind_of?(String)
|
||||
ERB.new(file).result(binding)
|
||||
else
|
||||
file.result(binding)
|
||||
send(:"_erb_#{file}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue