Jump to: navigation, search

Module:ProcessArgs/doc: Difference between revisions

(Created page with "{{documentation}} <!-- Documentation here --> This module allows arguments to be merged and normalised. This also has the side-effect of making the arguments a real table inst...")
 
mNo edit summary
 
Line 1: Line 1:
{{documentation}}
{{doc/start}}
<!-- Documentation here -->
<!-- Documentation here -->
This module allows arguments to be merged and normalised. This also has the side-effect of making the arguments a real table instead of an empty table with a metatable to access the args. This allows the <code>#</code> operator to work, as well as allowing new values to be added to the table, without being ignored when iterating.
This module allows arguments to be merged and normalised. This also has the side-effect of making the arguments a real table instead of an empty table with a metatable to access the args. This allows the <code>#</code> operator to work, as well as allowing new values to be added to the table, without being ignored when iterating.
Line 7: Line 7:
The <code>merge</code> function will merge two tables together, overwriting duplicate values from the second table with the first table's value, as well as doing the same as the <code>norm</code> function if the norm parameter is <code>true</code>.
The <code>merge</code> function will merge two tables together, overwriting duplicate values from the second table with the first table's value, as well as doing the same as the <code>norm</code> function if the norm parameter is <code>true</code>.
If the first parameter isn't a table, it is used as the value for the norm parameter, and it will automatically get the current frame's directly passed arguments table and merge it with the current frame's parent arguments table.
If the first parameter isn't a table, it is used as the value for the norm parameter, and it will automatically get the current frame's directly passed arguments table and merge it with the current frame's parent arguments table.
 
{{doc/end}}
<includeonly>
<includeonly>
<!-- Template categories/interwiki here -->
<!-- Template categories/interwiki here -->

Latest revision as of 14:42, 12 May 2017

Template-info.png Documentation

This module allows arguments to be merged and normalised. This also has the side-effect of making the arguments a real table instead of an empty table with a metatable to access the args. This allows the # operator to work, as well as allowing new values to be added to the table, without being ignored when iterating.

The norm function will normalise the arguments passed to it, trimming whitespace and setting empty arguments to nil. If a table isn't passed to the function, it will automatically get the current frame's parent arguments table.

The merge function will merge two tables together, overwriting duplicate values from the second table with the first table's value, as well as doing the same as the norm function if the norm parameter is true. If the first parameter isn't a table, it is used as the value for the norm parameter, and it will automatically get the current frame's directly passed arguments table and merge it with the current frame's parent arguments table.

This is the documentation page, it should be transcluded into the main template page. See Template:Doc for more information.




Cookies help us deliver our services. By using our services, you agree to our use of cookies.