Basic Usage¶
Importing ILLEX¶
import illex
Placeholder Substitution¶
Use curly braces to define placeholders that will be replaced with values:
illex.parse("Hello, {name}!", {"name": "World"})
# Output: 'Hello, World!'
Variable Assignment¶
Variables are defined using the @
prefix:
text = """
@name = John
@age = 30
Name: @name, Age: @age
"""
illex.parse(text, {})
# Output: 'Name: John, Age: 30'
Mathematical Expressions¶
text = """
@x = 10
@y = 20
Sum: :calc(@x + @y)
Product: :calc(@x * @y)
"""
illex.parse(text, {})
# Output: 'Sum: 30\nProduct: 200'
Calling Functions¶
Functions are called using the :
prefix followed by the function name and arguments in parentheses:
text = """
@name = joão silva
Formatted name: :capitalize(@name)
Uppercase: :uppercase(@name)
"""
illex.parse(text, {})
# Output: 'Formatted name: João silva\nUppercase: JOÃO SILVA'
Conditionals¶
text = """
@age = 20
Status: :if(@age >= 18, Adult, Minor)
"""
illex.parse(text, {})
# Output: 'Status: Adult'