class SidekiqUniqueJobs::Script::Template
Class Template
provides LUA script partial template rendering
@author Mikael Henriksson <mikael@mhenrixon.com>
Public Class Methods
Source
# File lib/sidekiq_unique_jobs/script/template.rb, line 14 def initialize(script_path) @script_path = script_path end
Public Instance Methods
Source
# File lib/sidekiq_unique_jobs/script/template.rb, line 33 def include_partial(relative_path) return if @partial_templates.key?(relative_path) @partial_templates[relative_path] = nil render(Pathname.new("#{@script_path}/#{relative_path}")) end
helper method to include a lua partial within another lua script
Source
# File lib/sidekiq_unique_jobs/script/template.rb, line 26 def render(pathname) @partial_templates ||= {} ::ERB.new(File.read(pathname)).result(binding) end
Renders a Lua script and includes any partials in that file
all `<%= include_partial '' %>` replaced with the actual contents of the partial
@param [Pathname] pathname the path to the
@return [String] the rendered Luascript