Mòideal:OutputBuffer/doc
This is the documentation page for Mòideal:OutputBuffer
(deasbaireachd⧼tpt-languages-separator⧽ ⧼tpt-languages-separator⧽eachdraidh⧼tpt-languages-separator⧽ceanglaichean⧼tpt-languages-separator⧽doc⧼tpt-languages-separator⧽bogsa-gainmhich⧼tpt-languages-separator⧽cùisean deuchainn)
This module is currently protected from editing. See the protection policy and protection log for more details. Please discuss any changes on the talk page; you may submit an edit request to ask an administrator to make an edit if it is uncontroversial or supported by consensus. You may also request that this page be unprotected. |
This module is subject to page protection. It is a highly visible module in use by a very large number of pages, or is substituted very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is protected from editing. |
This module provides an easy and efficient way to generate lengthy strings.
Ùsaid - Usage
First, load the module.
local newBuffer = require('Module:OutputBuffer')
Then, create the buffer and the functions that act on it.
local getBuffer, print, printf = newBuffer()
getBuffer
local text = getBuffer(sep)
Returns the contents of the buffer, with an optional separator string sep.
print(s)
Adds the string s to the buffer.
printf
printf(s, ...)
Adds the string s to the buffer. The string is formatted with any subsequent arguments, following the rules used for string.format.
Eisimpleirean - Examples
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."