Put templates into a proper scope
This commit is contained in:
parent
8811476f9f
commit
fcc9550fd5
|
@ -9,7 +9,8 @@ class BspwmTaskbar < Worker
|
||||||
if line == "\n"
|
if line == "\n"
|
||||||
self.write ""
|
self.write ""
|
||||||
else
|
else
|
||||||
self.write @config['mod']['bspwm_taskbar']['begin'].erb + line.chomp + @config['mod']['bspwm_taskbar']['end'].erb + "\n"
|
tmpl = Template.new(@config['mod']['bspwm_taskbar']['begin'] + line.chomp + @config['mod']['bspwm_taskbar']['end'])
|
||||||
|
self.write tmpl.render(@config, nil)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
16
moltenbar
16
moltenbar
|
@ -79,6 +79,19 @@ module Modules
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Template
|
||||||
|
def initialize(template)
|
||||||
|
@template = template
|
||||||
|
end
|
||||||
|
|
||||||
|
def render(config, data)
|
||||||
|
@config = config
|
||||||
|
@panel_data = data
|
||||||
|
|
||||||
|
return ERB.new(@template).result(binding)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Kill the workers.
|
# Kill the workers.
|
||||||
def cleanup(workers)
|
def cleanup(workers)
|
||||||
for w in workers do
|
for w in workers do
|
||||||
|
@ -164,6 +177,7 @@ IO.popen(lemonbar_cmd, "w+") do |pipe_lb|
|
||||||
mod_name, data = line.chomp.split("\0")
|
mod_name, data = line.chomp.split("\0")
|
||||||
panel_data[mod_name] = data
|
panel_data[mod_name] = data
|
||||||
|
|
||||||
pipe_lb.puts config['format'].erb
|
t = Template.new(config['format'])
|
||||||
|
pipe_lb.puts t.render(config, panel_data)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user