formatStrProp: Difference between revisions
Jump to navigation
Jump to search
m (Conversion script moved page FormatStrProp to formatStrProp: Converting page titles to lowercase) |
m (Text replacement - "source>" to "syntaxhighlight>") |
||
Line 6: | Line 6: | ||
<source lang="mtmacro" line> | <source lang="mtmacro" line> | ||
[h: formatStrProp(props, listFormat, entryFormat, separator) ] | [h: formatStrProp(props, listFormat, entryFormat, separator) ] | ||
</ | </syntaxhighlight> | ||
* listFormat is a string that is emitted once. It should contain the text "%list", which is replaced with the formatted items. | * listFormat is a string that is emitted once. It should contain the text "%list", which is replaced with the formatted items. | ||
* entryFormat is emitted once per item. Any instances of "%key" and "%value" in the string are replaced with the key or value for that setting. | * entryFormat is emitted once per item. Any instances of "%key" and "%value" in the string are replaced with the key or value for that setting. | ||
Line 15: | Line 15: | ||
[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: | Outputs: |
Revision as of 18:27, 14 March 2023
formatStrProp() Function
Returns a custom-formatted version of the property string.
Usage
<source lang="mtmacro" line> [h: formatStrProp(props, listFormat, entryFormat, separator) ] </syntaxhighlight>
- listFormat is a string that is emitted once. It should contain the text "%list", which is replaced with the formatted items.
- entryFormat 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 is emitted in between the formatted items.
Example
<source lang="mtmacro" line>
", " %key %value ", "")]
[h: props = "Strength=14 ; Constitution=8 ; Dexterity=13 ; Intelligence=4 ; Wisdom=18 ; Charisma=9"]
[formatStrProp(props, "%list</syntaxhighlight>
Outputs:
Strength | 14 |
Constitution | 8 |
Dexterity | 13 |
Intelligence | 4 |
Wisdom | 18 |
Charisma | 9 |