Sha256: 937ce7a249be71240d0b73d927ed58a7395a31aec57e78f9f45ebdccf34d08f5
Contents?: true
Size: 1.12 KB
Versions: 1
Compression:
Stored size: 1.12 KB
Contents
# frozen_string_literal: true module SidekiqUniqueJobs # Interface to dealing with .lua files # # @author Mikael Henriksson <mikael@zoolutions.se> module Script # # Class Template provides LUA script partial template rendering # # @author Mikael Henriksson <mikael@zoolutions.se> # class Template def initialize(script_path) @script_path = script_path 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 # def render(pathname) @partial_templates ||= {} ERB.new(File.read(pathname)).result(binding) end # helper method to include a lua partial within another lua script # 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 end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sidekiq-unique-jobs-7.0.0.beta2 | lib/sidekiq_unique_jobs/script/template.rb |