From: Steven Barth Date: Wed, 16 Jul 2008 07:26:36 +0000 (+0000) Subject: libs/web: Added luci.web.dispatcher.registered X-Git-Tag: 0.8.0~645 X-Git-Url: https://git.archive.openwrt.org/?p=project%2Fluci.git;a=commitdiff_plain;h=3ca2844c9fb46145e5c6023e8767137992e558cb libs/web: Added luci.web.dispatcher.registered --- diff --git a/libs/web/luasrc/dispatcher.lua b/libs/web/luasrc/dispatcher.lua index 735e2a715..756f3cc7d 100644 --- a/libs/web/luasrc/dispatcher.lua +++ b/libs/web/luasrc/dispatcher.lua @@ -324,6 +324,20 @@ function entry(path, target, title, order) return c end +-- Checks whether a node exists +function registered(...) + local c = context.tree + + for k,v in ipairs(arg) do + if not c.nodes[v] then + return false + end + + c = c.nodes[v] + end + return true +end + -- Fetch a dispatching node function node(...) local c = context.tree