The language for procedural
text processing code templating storytelling worldbuilding game dialogue character stats data structures mock data anything

Procgen made easy.

Rant is a high-level language for templating and procedural generation. It enables you to easily create dynamic templates, dialogue, stories, name generators, test data, and much more with minimal code.

Rant is intuitive

Think of Rant as the opposite of Regex: just as a regular expression compares inputs to a pattern, Rant generates matching outputs from a pattern. If you understand one, you already understand the other!

Rant is concise

Rant's standard library provides built-in utilities for many common use cases, cutting down on the amount of boilerplate you need to write.

Even for more complex generation tasks, Rant has your back. With its powerful set of synchronization, branching, and generation tools, you can get results with far less code than conventional programming languages.

Rant is flexible

Rant is infinitely configurable for a wide range of use cases ranging from natural language generation to simple code templating. What you do with it is up to you!

Features

Branching

Multiple possibilities? Not a problem. Branch off your code in unlimited directions by letting Rant pick randomly, or use one of the numerous other available selection modes.

The quick {red|brown|orange} fox...

##
Possible outputs:
  The quick red fox...
  The quick brown fox...
  The quick orange fox...
##
                        

Dynamic type system

Take advantage of Rant's dynamic type system with several built-in primitive and collection types. Influenced by languages like Lua and Python, Rant provides a familiar way to work with any kind of data.

<$lucky-number=[num:1;100]>

Your lucky number is <lucky-number>.
                        

Automatic formatting

Configure your programs to passively perform tasks like automatic capitalization, number formatting, and whitespace normalization on your output.

[case-fmt:upper]hello world!\n
[case-fmt:first]hello world!\n
[case-fmt:each-word]hello world!\n

##
Output: 
  HELLO WORLD!
  Hello world!
  Hello World!
##

Modules

Rant's module system allows you to create reusable libraries of functions and import them into other programs with a single function call.

# laughter.rant
<$module=@()>
[module/laugh: length] {
    [rep:<length>]{ha}
}
<module>

# main.rant
[require:laughter]
[laughter/laugh: 8] # "hahahahahahahaha"
                            

Block-based execution

Rant represents loops and conditional statements using blocks. Blocks can be configured with several special behaviors: they can insert list separators, control branch selection, and much more!

[rep:3][sep:" and "]
It just keeps {going}...

##
Output:
    It just keeps going and going and going...
##

Entanglement

If you need to synch­ronize RNG behavior in multiple places, Rant's built-in en­tanglement utilities make it easy to reuse RNG sequences in different parts of your program.

[fork:a]{woo|yee}[unfork]- 
[fork:a]{hoo|haw}[unfork]!

# Outputs "woo-hoo!" or "yee-haw!"

                            

Cross-platform

Rant is written in Rust, which means it can run on any­thing that has Rust compiler support. Enjoy seam­less port­ability of your Rant programs across Windows, Mac, Linux, and WebAssembly.

use rant::Rant;
use std::error::Error;

fn main() -> Result<(), Box<dyn Error>> {
    // Create a default Rant context
    let mut rant = Rant::with_random_seed();

    // Compile a simple program
    let program = rant.compile_quiet(
        "{Hello|Hi|Hey} world!"
    )?;

    // Run the program and print the output
    let output = rant.run(&program)?;
    println!("{}", output);

    Ok(())
}

Learn Rant

If you want to jump right in, the best place to start is the Get Started page. It goes over installing Rant, writing basic programs, and running them in the included CLI tool.

When your appetite for knowledge becomes insatiable, check out the Rant docs for information on every part of Rant.