✏️Interpolation
Expression Interpolation
Corgi has a special syntax that allows you to interpolate expressions inside your text. Simply write #{myExpression}
inside any text to evaluate the expression and include it in the text.
All expressions are escaped before getting printed.
If you ever just want to type a raw #
inside your text or strings, write ##
. The #
is the only character in corgi that needs escaping.
becomes
Text Interpolation
You can also interpolate text.
This might sound useless at first, but it allows you to add trailing spaces to lines.
If you add a !
after the #
, the text won't be escaped. This is super useful to use HTML character escapes.
Interpolated Elements
Sometimes you want to use a fairly short element directly in text. For that, you can use interpolated elements:
To use an expression in an interpolated element, simply swap out the [
brackets]
for {
curly braces}
. You can write everything that you can write when interpolating expressions.
You can also add classes and attributes to the interpolated element. Don't overdo it though, long chains of classes and attributes hurt readability.
String Interpolation
Corgi also allows expression interpolation in strings:
This also means that you need to escape hashes in strings using the regular double hash escape.
Last updated