<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
	<id>https://wiki.iccup.org/index.php?action=history&amp;feed=atom&amp;title=%D0%9C%D0%BE%D0%B4%D1%83%D0%BB%D1%8C%3APageVariableNamespace</id>
	<title>Модуль:PageVariableNamespace - История изменений</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.iccup.org/index.php?action=history&amp;feed=atom&amp;title=%D0%9C%D0%BE%D0%B4%D1%83%D0%BB%D1%8C%3APageVariableNamespace"/>
	<link rel="alternate" type="text/html" href="https://wiki.iccup.org/index.php?title=%D0%9C%D0%BE%D0%B4%D1%83%D0%BB%D1%8C:PageVariableNamespace&amp;action=history"/>
	<updated>2026-06-13T07:52:12Z</updated>
	<subtitle>История изменений этой страницы в вики</subtitle>
	<generator>MediaWiki 1.42.3</generator>
	<entry>
		<id>https://wiki.iccup.org/index.php?title=%D0%9C%D0%BE%D0%B4%D1%83%D0%BB%D1%8C:PageVariableNamespace&amp;diff=783&amp;oldid=prev</id>
		<title>DarkMuse: Новая страница: «--- -- @iCCup -- wiki=commons -- page=Module:PageVariableNamespace -- -- Please see https://github.com/iCCup/Lua-Modules to contribute --  local Class = require(&#039;Module:Class&#039;) local Logic = require(&#039;Module:Logic&#039;) local StringUtils = require(&#039;Module:StringUtils&#039;)  ---@class Namespace ---@field prefix string local Namespace = Class.new(function(self, prefix)     self.prefix = prefix end)  ---@param key wikiVariableKey ---@return string? function Namespace:ge...»</title>
		<link rel="alternate" type="text/html" href="https://wiki.iccup.org/index.php?title=%D0%9C%D0%BE%D0%B4%D1%83%D0%BB%D1%8C:PageVariableNamespace&amp;diff=783&amp;oldid=prev"/>
		<updated>2024-09-24T18:32:09Z</updated>

		<summary type="html">&lt;p&gt;Новая страница: «--- -- @iCCup -- wiki=commons -- page=Module:PageVariableNamespace -- -- Please see https://github.com/iCCup/Lua-Modules to contribute --  local Class = require(&amp;#039;Module:Class&amp;#039;) local Logic = require(&amp;#039;Module:Logic&amp;#039;) local StringUtils = require(&amp;#039;Module:StringUtils&amp;#039;)  ---@class Namespace ---@field prefix string local Namespace = Class.new(function(self, prefix)     self.prefix = prefix end)  ---@param key wikiVariableKey ---@return string? function Namespace:ge...»&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;---&lt;br /&gt;
-- @iCCup&lt;br /&gt;
-- wiki=commons&lt;br /&gt;
-- page=Module:PageVariableNamespace&lt;br /&gt;
--&lt;br /&gt;
-- Please see https://github.com/iCCup/Lua-Modules to contribute&lt;br /&gt;
--&lt;br /&gt;
&lt;br /&gt;
local Class = require(&amp;#039;Module:Class&amp;#039;)&lt;br /&gt;
local Logic = require(&amp;#039;Module:Logic&amp;#039;)&lt;br /&gt;
local StringUtils = require(&amp;#039;Module:StringUtils&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
---@class Namespace&lt;br /&gt;
---@field prefix string&lt;br /&gt;
local Namespace = Class.new(function(self, prefix)&lt;br /&gt;
    self.prefix = prefix&lt;br /&gt;
end)&lt;br /&gt;
&lt;br /&gt;
---@param key wikiVariableKey&lt;br /&gt;
---@return string?&lt;br /&gt;
function Namespace:get(key)&lt;br /&gt;
    return StringUtils.nilIfEmpty(mw.ext.VariablesLua.var(self.prefix .. key))&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
---@param key wikiVariableKey&lt;br /&gt;
---@param value wikiVariableValue&lt;br /&gt;
function Namespace:set(key, value)&lt;br /&gt;
    mw.ext.VariablesLua.vardefine(self.prefix .. key, Logic.emptyOr(value))&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
---@param key wikiVariableKey&lt;br /&gt;
function Namespace:delete(key)&lt;br /&gt;
    self:set(key, nil)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
---@class PageVariableNamespaceCachedTable&lt;br /&gt;
---@field results table&lt;br /&gt;
---@field table table&lt;br /&gt;
local CachedTable = Class.new(function(self, tbl)&lt;br /&gt;
    self.results = {}&lt;br /&gt;
    self.table = tbl&lt;br /&gt;
end)&lt;br /&gt;
&lt;br /&gt;
---@param key string|number&lt;br /&gt;
---@return unknown&lt;br /&gt;
function CachedTable:get(key)&lt;br /&gt;
    if not self.results[key] then&lt;br /&gt;
        self.results[key] = self.table:get(key)&lt;br /&gt;
    end&lt;br /&gt;
    return self.results[key]&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
---@param key string|number&lt;br /&gt;
---@param value string|number|nil&lt;br /&gt;
function CachedTable:set(key, value)&lt;br /&gt;
    self.results[key] = nil&lt;br /&gt;
    self.table:set(key, value)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
---@param key string|number&lt;br /&gt;
function CachedTable:delete(key)&lt;br /&gt;
    self:set(key, nil)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
---@class PageVariableNamespace&lt;br /&gt;
---@operator call(string?):Namespace&lt;br /&gt;
local PageVariableNamespace = {}&lt;br /&gt;
&lt;br /&gt;
---@param options {cached: boolean?, separator: string?, namespace: string?}?&lt;br /&gt;
---@return {cached: boolean, separator: string, namespace: string?}&lt;br /&gt;
---@overload fun(options: string): {cached: boolean, separator: string, namespace: string?}&lt;br /&gt;
---@overload fun(): {cached: false, separator: string}&lt;br /&gt;
function PageVariableNamespace.readOptions(options)&lt;br /&gt;
    local parsedOptions = {}&lt;br /&gt;
&lt;br /&gt;
    options = options or {}&lt;br /&gt;
    if type(options) == &amp;#039;string&amp;#039; then&lt;br /&gt;
        parsedOptions = {namespace = options}&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    parsedOptions.cached = Logic.nilOr(options.cached, false)&lt;br /&gt;
    parsedOptions.separator = options.separator or &amp;#039;.&amp;#039;&lt;br /&gt;
    parsedOptions.namespace = parsedOptions.namespace or options.namespace&lt;br /&gt;
&lt;br /&gt;
    return parsedOptions&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
PageVariableNamespace.Namespace = Namespace&lt;br /&gt;
PageVariableNamespace.CachedTable = CachedTable&lt;br /&gt;
&lt;br /&gt;
setmetatable(PageVariableNamespace, {&lt;br /&gt;
    __call = function(_, options_)&lt;br /&gt;
        local options = PageVariableNamespace.readOptions(options_)&lt;br /&gt;
&lt;br /&gt;
        local prefix = options.namespace and options.namespace .. options.separator or &amp;#039;&amp;#039;&lt;br /&gt;
        local pageVars = Namespace(prefix)&lt;br /&gt;
        return options.cached&lt;br /&gt;
            and CachedTable(pageVars)&lt;br /&gt;
            or pageVars&lt;br /&gt;
    end,&lt;br /&gt;
})&lt;br /&gt;
&lt;br /&gt;
return PageVariableNamespace&lt;/div&gt;</summary>
		<author><name>DarkMuse</name></author>
	</entry>
</feed>