Working with Text
Text values (strings) are one of the most common data types in Rhyme. Here’s how to work with them effectively.
Creating Text Values
There are three ways to create text in Rhyme:
// Double quotes - most common
$message = "Hello, World!"
// Single quotes - useful when text contains double quotes
$quote = 'She said "Hello" to me'
// Backticks - for multi-line text
$poem = `Roses are red
Violets are blue
Rhyme makes apps
And so can you!`
Text Operations
Text in UI Elements
Text values are used throughout your UI:
.text "Welcome to my app"
.button "Click Me"
.title $page-title
Special Characters
To include special characters in text:
// Line breaks in multi-line strings
$address = `123 Main St
Apartment 4B
New York, NY`
Common Patterns
Dynamic Messages
$user-name = "Alice"
$score = 100
.text "Welcome back, $user-name! Your score is $score"
Conditional Text
if $is-logged-in
$status = "Online"
else
$status = "Offline"
.text "Status: $status"
Remember: Text values are flexible and can be combined with variables to create dynamic, personalized content in your apps!