formatStrProp: Difference between revisions
Jump to navigation
Jump to search
(New page: ==Function formatStrProp== Returns a custom-formatted version of the property string. ===Usage=== <source lang="mtmacro" line> [h: formatStrProp(props, listFormat, entryFormat, separator)...) |
Full Bleed (talk | contribs) m (Added delim to usage and Parameters section.) |
||
(8 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
= | {{MacroFunction | ||
Returns a custom-formatted version of the property string. | |name=formatStrProp | ||
|description=Returns a custom-formatted version of the property string. | |||
|usage= | |||
< | <syntaxhighlight lang="mtmacro" line> | ||
[h: formatStrProp( | [h: formatStrProp(proplist, listFormat, entryFormat, separator)] | ||
</ | [h: formatStrProp(proplist, listFormat, entryFormat, separator, delim)] | ||
</syntaxhighlight> | |||
'''Parameters''' | |||
{{param|proplist|String property list to extract data from.}} | |||
{{param|listFormat|String that is emitted once. It should contain the text "%list", which is replaced with the formatted items.}} | |||
{{param|entryFormat|String that is emitted once per item. Any instances of "%key" and "%value" in the string are replaced with the key or value for that setting.}} | |||
{{param|separator|Character(s) emitted in between the formatted items.}} | |||
{{param|delim|Delimiter between fields (default is ";").}} | |||
|example= | |||
< | <syntaxhighlight lang="mtmacro" line> | ||
[h: props = "Strength=14 ; Constitution=8 ; Dexterity=13 ; Intelligence=4 ; Wisdom=18 ; Charisma=9"] | [h: props = "Strength=14 ; Constitution=8 ; Dexterity=13 ; Intelligence=4 ; Wisdom=18 ; Charisma=9"] | ||
[formatStrProp(props, "<table border=1>%list</table>", "<tr> <td><b>%key</b></td> <td>%value</td> </tr>", "")] | [formatStrProp(props, "<table border=1>%list</table>", "<tr> <td><b>%key</b></td> <td>%value</td> </tr>", "")] | ||
</ | </syntaxhighlight> | ||
Outputs: | |||
<table border=1> | |||
<tr><td><b>Strength</b></td><td>14</td></tr> | |||
<tr><td><b>Constitution</b></td><td>8</td></tr> | |||
<tr><td><b>Dexterity</b></td><td>13</td></tr> | |||
<tr><td><b>Intelligence</b></td><td>4</td></tr> | |||
<tr><td><b>Wisdom</b></td><td>18</td></tr> | |||
<tr><td><b>Charisma</b></td><td>9</td></tr> | |||
</table> | |||
}} | |||
[[Category:String Property List Function]] |
Latest revision as of 23:59, 14 November 2024
formatStrProp() Function
Returns a custom-formatted version of the property string.
Usage
[h: formatStrProp(proplist, listFormat, entryFormat, separator)]
[h: formatStrProp(proplist, listFormat, entryFormat, separator, delim)]
Parameters
proplist
- String property list to extract data from.listFormat
- String that is emitted once. It should contain the text "%list", which is replaced with the formatted items.entryFormat
- String that is emitted once per item. Any instances of "%key" and "%value" in the string are replaced with the key or value for that setting.separator
- Character(s) emitted in between the formatted items.delim
- Delimiter between fields (default is ";").
Example
[h: props = "Strength=14 ; Constitution=8 ; Dexterity=13 ; Intelligence=4 ; Wisdom=18 ; Charisma=9"]
[formatStrProp(props, "<table border=1>%list</table>", "<tr> <td><b>%key</b></td> <td>%value</td> </tr>", "")]
Outputs:
Strength | 14 |
Constitution | 8 |
Dexterity | 13 |
Intelligence | 4 |
Wisdom | 18 |
Charisma | 9 |