Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
IndicWiki Sandbox
Search
Search
English
Log in
Personal tools
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Module:Buffer/doc
(section)
Module
Discussion
English
Read
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===for Element-Buffers=== {{code|lang=lua|Element-Buffer .. value}} {{code|lang=lua|value .. Element-Buffer}} {{code|lang=lua|Element-Buffer .. Element-Buffer}} To recap and expand upon [[#Element-Buffer|§ Element-Buffer-object]], the behavior of this op depends on whether its parent Buffer-HTML is {{luaref|mw.html.create|selfClosing|y}} or if the other ''value'' is also an Element-Buffer. Also, the final result always includes the outer HTML object (i.e., the tag) in some manner. For Element-Buffers of "open" tags, this op creates a table with a metaindex that references the parent of the Element-Buffer. The table is then effectively a "mirror" of the parent Buffer-HTML object except that it contains an empty table at <code>table.nodes</code>{{--}} the index of the Element-Buffer within its parent. This then populates the mirror's inner table with the string of the Element-Buffer and the other value, validated left-to-right, in a manner not unlike what this does with the temporary table it creates when concatenating non-element Buffers to another value. This then returns the mirror table through the __tostring metamethod of the mw.html library, yielding a string which resembles that of the parent tag but with ''value'' inserted in front of or behind the original inner text depending on whether ''value'' was to the left or right of the <code>..</code> operator, respectively. When the selfClosing property of the parent evaluates true, this operates on the parent instead of the Element-Buffer{{--}}i.e., the resulting string will have ''value'' on the outside as opposed to within the tag (placing it inside would be pointless since selfClosing tags do not show inner contents). If both operated objects are Element-Buffers, this mirrors the parent of the first. The inner table of the mirror is then populated by inserting the string of the first Element-Buffer followed by the string the parent Buffer-HMTL of the second. The resulting string would be as though the parent of the second were the last node of the first parent. Note that this Element-to-Element rule does not apply when the first Buffer belongs to a selfClosing tag (in which case, this behaves as though the selfClosing parent were to the left of the operator, returning a string with the selfClosing tag inside the tag of the second Element-Buffer in front the latter's inner contents.) Finally, this combines an Element-Buffer and a table ''value'' which has no metatable by passing the table as ''args'' for {{luaself|pre=Element-|:_add}} with the mirror of the Element-Buffer as the "self". This avoids permanently changing the parent Buffer-HTML by setting a new table at <code>table.attributes</code> or <code>table.styles</code> in the mirror the first time methods such as {{luaref|mw.html:css|plain=y}}, {{luaref|mw.html:attr|plain=y}}, {{luaref|mw.html:addClass|plain=y}}, etc. attempt to access those tables, copying the original's via the recursive form of {{luaself|:_cc}}. Note however that permanent changes may be made to other objects whenever methods such as via {{luaself|args.done}} or {{luaself|args.globalFunction}} are keyed to navigate beyond the mirror or "sandbox". {{anchor|MBpairs}}
Summary:
Please note that all contributions to IndicWiki Sandbox may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
My wiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Toggle limited content width