Unlike normal gcode_macros, Dynamic Macros supports receiving variable updates within the same macro. For example, the following macro will show the same output in both M117s:
[gcode_macro STATIC_MOVE]gcode:G28M117 Before:{printer.toolhead.position.z}# Above displays position before macro runG90G1 Z20M117 After:{printer.toolhead.position.z}# Above displays same position
However, this macro will show different outputs based on the current Z position of the toolhead:
[gcode_macro DYNAMIC_MOVE]gcode:G28M117 Before:{printer.toolhead.position.z}# Above displays position after G28G90G1 Z20M117 After:{printer.toolhead.position.z}# Above displays position after G1
Notice the large whitespaces. Three newline characters (two blank lines) between code segments denotes a variable update. However, some variables won't be preserevd across the whitespace.