aboutsummaryrefslogtreecommitdiff
path: root/mensa/frontends/plain-text.py
diff options
context:
space:
mode:
authorGabriel Pérez-Cerezo <gabriel@gpcf.eu>2018-09-18 00:37:18 +0200
committerGabriel Pérez-Cerezo <gabriel@gpcf.eu>2018-09-18 00:37:18 +0200
commit971f633eaadec381bda398f024bab42fa1311bd0 (patch)
tree134c0665343ea52d123af247be2300972575fb77 /mensa/frontends/plain-text.py
parent3d4cb8555196a08347e373b6e542f80159155261 (diff)
downloadmensa-971f633eaadec381bda398f024bab42fa1311bd0.tar.gz
mensa-971f633eaadec381bda398f024bab42fa1311bd0.tar.bz2
mensa-971f633eaadec381bda398f024bab42fa1311bd0.zip
added templating, Version 0.4.1
You can now use templating by creating a file containing "$$TEXT$$" somewhere. $$TEXT$$ will be replaced with the menu.
Diffstat (limited to 'mensa/frontends/plain-text.py')
-rw-r--r--mensa/frontends/plain-text.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/mensa/frontends/plain-text.py b/mensa/frontends/plain-text.py
index 8f3f736..cbd71e7 100644
--- a/mensa/frontends/plain-text.py
+++ b/mensa/frontends/plain-text.py
@@ -24,7 +24,14 @@ class TextRenderer(IPlugin) :
r=r+"Distance: %.2f km\n" % base.dist(options["pos"], restaurant.pos)
r= r + "".join([category+"\n" + "".join([self.render_line(i) for i in items]) for category,items in food.items()])
- print(r)
+
+ if options.get("template") :
+ f = open(options["template"], "r")
+ template = f.read()
+ f.close()
+ print(template.replace("$$TEXT$$", r))
+ else :
+ print(r)
def register_renderer(self) :
base.register_renderer(base.Renderer("plain-text", "Plain Text Renderer", self))