Modul:OutputBuffer

Fra Wikipedia, den frie encyklopedi
Hopp til navigering Hopp til søk
Dokumentasjonsikon Moduldokumentasjon [vis] [rediger] [historikk] [oppdater]

Usage[rediger kilde]

Simply place "#invoke:OutputBuffer|" before a call to a template. For example, {{#invoke:DemoTemplate|Convert|10|km|nmi|abbr=off}} yields the following:

Skriptfeil: Modulen returnerte en function-verdi. Det forventes at den returnerer en eksporttabell.

This module handles both named and positional parameters as well as equals signs in both parameter names and values correctly, so this (for example) will work: {{#invoke:DemoTemplate|echo|1=Some parameter with an = sign in it}}

Skriptfeil: Modulen returnerte en function-verdi. Det forventes at den returnerer en eksporttabell.

Note, however, that pipes, curly braces, etc. are not currently handled correctly by this module, so this (for example) will not work correctly: {{#invoke:DemoTemplate|echo|foo{{!}}bar}}

Skriptfeil: Modulen returnerte en function-verdi. Det forventes at den returnerer en eksporttabell.


return function()
	local buffer = {}
	return function(sep)
		local b = buffer
		buffer = {}
		return table.concat(b, sep)
	end,
	function(text)
		buffer[#buffer + 1] = text
	end,
	function(...)
		buffer[#buffer + 1] = string.format(...)
	end
end