Module:ОутпутБуффер/доc
Appearance
This is the documentation page for Modul:OutputBuffer
Тҳис модуле провидес ан эасй анд эффиcиэнт wай то генерате ленгтҳй стрингс.
Усаге
Фирст, лоад тҳе модуле.
local newBuffer = require('Module:OutputBuffer')
Тҳен, cреате тҳе буффер анд тҳе фунcтионс тҳат аcт он ит.
local getBuffer, print, printf = newBuffer()
гетБуффер
local text = getBuffer(sep)
Ретурнс тҳе cонтенц оф тҳе буффер, wитҳ ан оптионал сепаратор стринг сеп.
принт
print(s)
Аддс тҳе стринг с то тҳе буффер.
принтф
printf(s, ...)
Аддс тҳе стринг с то тҳе буффер. Тҳе стринг ис форматтед wитҳ анй субсеқуэнт аргуменц, фоллоwинг тҳе рулес усед фор стринг.формат.
Эхампле
local newBuffer = require('Module:OutputBuffer')
local p = {}
function p.main()
local getBuffer, print, printf = newBuffer()
print('Welcome to the English Wikipedia.')
printf('There are currently %d articles on this site.', mw.site.stats.articles)
return getBuffer(' ')
end
return p
-- Assuming this module's name is "TestModule", and that mw.site.stats.articles returns 4500000,
-- {{#invoke:TestModule|main}} would output:
-- "Welcome to the English Wikipedia. There are currently 4500000 articles on this site."