Tim Engine's syntax is indentation-based, similar to Nim, Ruby or Python. This means that the structure of your code is determined by its indentation level, making it clean and easy to read. Inspired by the Emmet syntax, Tim allows you to create complex HTML structures with minimal code using a simple and intuitive syntax. 👌
🔗Quick Example
Here is a simple example of Tim syntax for a basic HTML structure using Bootstrap 5:
div.container > div.row > div.col-12
h1.display-4.fw-bold: "Welcome to Tim Engine!"
p.lead: "Tim Engine is a powerful templating engine and scripting language for developers."
a.btn.btn-primary.px-4.rounded-3
href="https://example.com": "Get Started"🔗Syntax - Basics
- Elements: HTML elements are defined by their tag name, followed by optional classes and attributes. For example,
div.containercreates adivelement with the classcontainer. - Nesting: Child elements are indented under their parent element. For example, the
h1andpelements are nested inside thediv.col-12element. - Text Content: To add text content to an element, you can use a colon
:followed by the text. For example,h1.title: "Welcome to Tim Engine!". - Attributes: You can add attributes to elements using the
attr=valuesyntax. For example,href="https://example.com". - Shorthand for IDs: You can use
#to define an element's ID. For example,div#maincreates adivelement with the IDmain. - Shorthand for Classes: You can use
.to define an element's class. For example,div.containercreates adivelement with the classcontainer. - Sibling Elements: You can use the
>operator to create sibling elements or indent them to create child elements.
🔗The language
Tim engine is a Domain-Specific Language (DSL), it is designed to be used for creating HTML templates, Tim includes a powerful scripting language that allows you to add the dynamic behaviour to your templates and generate content based on conditions, loops, and more.
Tim Engine features a strongly-typed data model, supporting primitive types like strings, numbers, booleans, as well as composite types such as arrays and objects. You can leverage built-in functions or define custom functions to efficiently manipulate data and generate dynamic content.
🔗Data Types
Tim Engine supports a variety of data types, including:
| name | type | description |
string | Primitive | Represents a sequence of characters. |
int | Primitive | Represents a whole number. |
float | Primitive | Represents a number with a fractional part. |
boolean | Primitive | Represents a logical value, either true or false. |
array | Composite | Represents an ordered collection of values, which can be of any type. |
object | Composite | Represents a collection of key |