Rtl

screenshot of Rtl
html

A template language for Roc with compile time validation and tag unions

Overview

Roc Template Language (RTL) is an innovative template language designed specifically for the Roc programming language, offering compile-time validation and support for tag unions. Whether you're developing web applications or other text-based projects, RTL seamlessly integrates with Roc, allowing users to create robust templates efficiently. With its simple syntax and powerful features, RTL enables developers to generate HTML and other content types while ensuring type safety and eliminating runtime errors.

The process begins with crafting a template in a .rtl file, and running the RTL command in the same directory generates a Pages.roc file. This auto-generated file incorporates a Roc function for each template, letting developers quickly produce dynamic content by passing a model argument. With RTL, creating structured, complex templates becomes straightforward and enjoyable, blending the familiarity of Roc's syntax with the flexibility of a modern templating system.

Features

  • Compile-Time Validation: RTL ensures templates are validated at compile time, reducing potential runtime errors and improving overall reliability.
  • Type Safety: The generated Pages.roc file integrates seamlessly into your Roc project, providing type checking without extra configuration.
  • Value Insertion: Use double curly brackets to easily interpolate values into your templates while maintaining security by escaping HTML to avert XSS vulnerabilities.
  • List Expansion: Define patterns for list elements to dynamically generate content for lists with any normal Roc patterns.
  • Conditional Content: Include or exclude content based on conditions with simple when expressions and the option for else blocks, simplifying content management.
  • Raw Interpolation: For scenarios requiring unescaped HTML, triple brackets allow for raw content insertion, suitable for different content types or combined templates.
  • Hot Reloading: Achieve a nearly real-time development experience with a specific command setup, facilitating rapid iteration and testing.
  • Syntax Highlighting: Enhance readability in your development environment by setting up file associations for RTL-specific syntax highlighting in editors like VS Code.
html
HTML

HTML templates are pre-designed and pre-built web pages that can be customized and used as a basis for building websites. They often include common elements such as headers, footers, menus, and content sections, and can be easily edited using HTML and CSS to fit specific branding and content needs.