aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--klippy/extras/gcode_macro.py6
-rw-r--r--test/klippy/macros.cfg7
2 files changed, 13 insertions, 0 deletions
diff --git a/klippy/extras/gcode_macro.py b/klippy/extras/gcode_macro.py
index a29e1248..0ad695b6 100644
--- a/klippy/extras/gcode_macro.py
+++ b/klippy/extras/gcode_macro.py
@@ -28,6 +28,12 @@ class GetStatusWrapper:
self.eventtime = self.printer.get_reactor().monotonic()
self.cache[sval] = res = dict(po.get_status(self.eventtime))
return res
+ def __contains__(self, val):
+ try:
+ self.__getitem__(val)
+ except KeyError as e:
+ return False
+ return True
# Wrapper around a Jinja2 template
class TemplateWrapper:
diff --git a/test/klippy/macros.cfg b/test/klippy/macros.cfg
index d766c9d6..4886425f 100644
--- a/test/klippy/macros.cfg
+++ b/test/klippy/macros.cfg
@@ -106,6 +106,12 @@ gcode:
M112
{% endif %}
+[gcode_macro TEST_in]
+gcode:
+ {% if "abc" in printer or "gcode" not in printer %}
+ M112
+ {% endif %}
+
# Main test start point
[gcode_macro TESTIT]
gcode:
@@ -113,3 +119,4 @@ gcode:
TEST_expression
TEST_variable
TEST_param T=123
+ TEST_in