Content deleted Content added
save |
save |
||
Line 31:
====Buffer:_====
{{luaself|:_|args='string'|args2=value, pos, raw|
In rough terms, <code>Buffer:_'string1':_'string2'</code> is the same as <code>Buffer = Buffer..'string1'..'string2'</code>. (If it helps, imagine
{{anchor|valid}}<u>No-op values</u><br />
If passed {{code|value}} that is any of the following, then {{code|:_}} will be a no-op: * {{luaref|nil|plain=y}}
* {{luaref|boolean|plain=y}}
* an empty {{luaref|string
* a {{luaref|table|plain=y}} without a {{luaref|__tostring}} metamethod and which table[1] is nil or false.
Tables lacking a __string metamethod are converted to string via {{luaref|table.concat}}.
For all other data values, the result of {{luaref|tostring|args=value}} would be inserted
You may set optional {{code|raw}} argument to true to insert a value without tostring coercion (e.g. an mw.html object while retaining the ability to change the mw.html object at that position). Note however that raw insertion will cause all future conversions of the Buffer to be handled by {{luaself|:_all}} instead of table.concat, which could result in a small [[#performance|performance]] penalty that may be undesirable for highly transcluded modules. (See [[#Tips]] for ways to avoid using raw)▼
▲
When passed {{code|pos}} of type {{luaref|number|plain=y}}, the argument is the same as for {{luaref|table.insert|args=table, '''pos''', value}}. (In fact, assuming a [[#valid]] value, {{luaself|:_|args=''value'', 1}} is exactly the same as {{luaref|table.insert|args=Buffer, 1, ''value''}}.)
The treatment of {{code|pos}} of type {{luaref|string|plain=y}} is unconventional in that the length of the Buffer is added to {{code|pos}}. In other words, {{luaself|:_|args='string', '-1'}} is the same as {{luaself|:_|args='string', #Buffer - 1}} (obviating the need to store Buffer as a local variable just to use the {{luaref|Length operator|length operator|plain=y}}).
====Buffer:_all====
{{luaself|:_all|args={ ''value'', ... }|args2={ ''value'', ''value'' {{=}} ''pos'', ... }, ''value-key''}}
====Buffer:_in====
|