Daniel Poelzleithner committed e19b0b5

allow execptions an slot.reset_all()

this is usefull when an error is detected deep into a view where you want redirect
to something usefull, but still save some slots like notice and error slots

  • Participants
  • Parent commits fc98e5c

Comments (0)

Files changed (1)


+  except       =  except, -- Reset all slots, except slots named in this list
 Calling this function resets all slots to be empty.
-function slot.reset_all()
+function slot.reset_all(args)
+  local saved = {}
+  if args and args.except then
+    for i,key in ipairs(args.except) do
+      saved[key] = slot._data[key]
+    end
+  end
   slot._data = setmetatable({}, slot._data_metatable)
+  if saved then
+    for key,value in pairs(saved) do
+      slot._data[key] = value
+    end
+  end