Difference between revisions of "Inline Expressions"

From MSX - Wiki
Jump to navigation Jump to search
Line 24: Line 24:
 
Colored text. The <code>{COLOR}</code> part must be replaced with the color value and the <code>{TEXT}</code> part must be replaced with any text. Please see [[Colors]] for possible color values.
 
Colored text. The <code>{COLOR}</code> part must be replaced with the color value and the <code>{TEXT}</code> part must be replaced with any text. Please see [[Colors]] for possible color values.
 
|-
 
|-
| <code>{chr:{CHARACTER}}</code> || <code>{chr:copy}</code> || data-sort-value='''145'''|'''0.1.145''' ||  
+
| <code>{chr:{CHARACTER}}</code> || <code>{chr:copy}</code><br/><code>{chr:#169}</code> || data-sort-value='''145'''|'''0.1.145''' ||  
Character entity. The <code>{CHARACTER}</code> part must be replaced with an HTML character entity name or number without an ampersand (<code>&</code>) at the beginning and a semicolon (<code>;</code>) at the end. Please see following examples.
+
Character entity. The <code>{CHARACTER}</code> part must be replaced with an HTML character entity name or number without an ampersand (<code>&</code>) at the beginning and a semicolon (<code>;</code>) at the end (e.g. <code>"{chr:copy}"</code> → <code>"&amp;copy;"</code> → "&copy;").
* <code>"{chr:copy}"</code> → <code>"&amp;copy;"</code> → "&copy;"
 
* <code>"{chr:#169}"</code> → <code>"&amp;#169;"</code> → "&#169;"
 
 
|-
 
|-
| <code>{chr:{COLOR}:{CHARACTER}}</code> || <code>{chr:msx-red:copy}</code> || data-sort-value='''145'''|'''0.1.145''' ||  
+
| <code>{chr:{COLOR}:{CHARACTER}}</code> || <code>{chr:msx-red:copy}</code><br/><code>{chr:msx-red:#169}</code> || data-sort-value='''145'''|'''0.1.145''' ||  
Colored character entity. The <code>{COLOR}</code> part must be replaced with the color value and the <code>{CHARACTER}</code> part must be replaced with an HTML character entity name or number without an ampersand (<code>&</code>) at the beginning and a semicolon (<code>;</code>) at the end. Please see [[Colors]] for possible color values. Please see following examples.
+
Colored character entity. The <code>{COLOR}</code> part must be replaced with the color value and the <code>{CHARACTER}</code> part must be replaced with an HTML character entity name or number without an ampersand (<code>&</code>) at the beginning and a semicolon (<code>;</code>) at the end (e.g. <code>"{chr:msx-red:copy}"</code> → <code>"<span style="color:#c9302c">&amp;copy;</span>"</code> → "<span style="color:#c9302c">&copy;</span>"). Please see following examples.
* <code>"{chr:msx-red:copy}"</code> → <code>"<span style="color:#c9302c">&amp;copy;</span>"</code> → "<span style="color:#c9302c">&copy;</span>"
 
* <code>"{chr:msx-red:#169}"</code> → <code>"<span style="color:#c9302c">&amp;#169;</span>"</code> → "<span style="color:#c9302c">&#169;</span>".
 
 
|-
 
|-
 
| <code>{context:{PROPERTY}}</code> || <code>{context:label}</code> || data-sort-value=0|0.1.0 ||  
 
| <code>{context:{PROPERTY}}</code> || <code>{context:label}</code> || data-sort-value=0|0.1.0 ||  

Revision as of 09:57, 28 March 2022

Most of the text properties support inline expressions for adding icons or coloring text parts. Each expression starts with character { and ends with character }. Nested expressions are not supported.

Expression syntax
Expression Example Since Version Description
{sp} {sp} 0.1.0

Non-breakable space.

{tb} {tb} 0.1.0

Non-breakable tab.

{br} {br} 0.1.0

Line break.

{ico:{ICON}} {ico:home} 0.1.0

Icon. The {ICON} part must be replaced with the icon name. Please see Icons for possible values.

{ico:{COLOR}:{ICON}} {ico:msx-red:home} 0.1.0

Colored icon. The {COLOR} part must be replaced with the color value and the {ICON} part must be replaced with the icon name. Please see Colors and Icons for possible values.

{txt:{COLOR}:{TEXT}} {txt:msx-red:Hello there!} 0.1.0

Colored text. The {COLOR} part must be replaced with the color value and the {TEXT} part must be replaced with any text. Please see Colors for possible color values.

{chr:{CHARACTER}} {chr:copy}
{chr:#169}
0.1.145

Character entity. The {CHARACTER} part must be replaced with an HTML character entity name or number without an ampersand (&) at the beginning and a semicolon (;) at the end (e.g. "{chr:copy}""&copy;" → "©").

{chr:{COLOR}:{CHARACTER}} {chr:msx-red:copy}
{chr:msx-red:#169}
0.1.145

Colored character entity. The {COLOR} part must be replaced with the color value and the {CHARACTER} part must be replaced with an HTML character entity name or number without an ampersand (&) at the beginning and a semicolon (;) at the end (e.g. "{chr:msx-red:copy}""&copy;" → "©"). Please see following examples.

{context:{PROPERTY}} {context:label} 0.1.0

This is a very special inline expression and can only be used inside the data property of a template object. It is used to reference properties of a templated item. The {PROPERTY} part must be replaced with any property that is available in the templated item (e.g. if the item has a property "customProperty": "customValue", it can be referenced with "{context:customProperty}""customValue"). The referenced property must exist, otherwise the expression can not be replaced and will remain as it is (e.g. "{context:missingProperty}""{context:missingProperty}"). Additionally, the value of the referenced property must be indicated as string, otherwise the expression is removed (e.g. "{context:invalidProperty}""").

Note: Since version 0.1.110, also the properties, live, selection, and options property of a template object supports this inline expression.

{unknown} {unknown} 0.1.0

Any unknown expression is returned as it is without the braces (e.g. "{unknown}""unknown").

Related Live API[edit]

Related Hidden Features[edit]