Certain features, such as the default AutoRoom name and the introduction message allow for a custom templated text to be set. This document will explain how to create custom templates, and go over all template options.
Jinja2/Liquid #
If you’ve ever used Jinja2 or Liquid, the templates here are largely the same. The below documentation (especially the filters) lists the more useful features you might need (things not related to list or HTML manipulation).
Variables #
Variables are dynamic bits of information you can add to your templates. Variables will always use double braces ({{ variable }}). Below are the supported variables you can use:
| Variable | Description |
|---|---|
{{username}}, {{user.name}}, or {{user.nickname}} |
The AutoRoom Owners display name, or server nickname if set |
{{user.mention}} |
The AutoRoom Owners mention |
{{user.global_name}} |
The AutoRoom Owners global display name (server nickname is ignored) |
{{user.username_raw}} |
The AutoRoom Owners username |
{{user.id}} |
The AutoRoom Owners ID |
{{user.is_bot}} |
Whether or not the AutoRoom Owner is a bot |
{{user.game}} |
The game the AutoRoom Owner is currently playing, if there is one |
{{source.name}} |
The AutoRoom Sources display name |
{{source.mention}} |
The AutoRoom Sources mention |
{{autoroom.name}} |
The AutoRooms display name (introduction message only) |
{{autoroom.mention}} |
The AutoRooms mention (introduction message only) |
Filters #
Filters modify data. They can modify variables or hardcoded information. They are also used inside double braces ({{ variable | filter }}), and they can be chained together if needed ({{ variable | filter1 | filter2 }}). Below are the supported fiters you can use:
abs #
Returns the absolute value of a number.
|a - b| = {{ (a - b)|abs }}
-> |2 - 4| = 2
bool #
Converts the value into a boolean value.
This behaves the same as the if statement does with regards to handling of boolean values.
{{ 42|bool }} -> true
capitalize #
Convert the string with all its characters lowercased apart from the first char which is uppercased.
{{ "this is a SENTENCE!"|capitalize }} -> This is a sentence!
default #
If the value is undefined it will return the passed default value, otherwise the value of the variable:
{{ user.game|default("AutoRoom Owner isn't playing a game") }}
Setting the optional second parameter to true will also treat falsy values as undefined, e.g. empty strings:
{{ ""|default("string was empty", true) }}
float #
Converts a value into a float.
{{ "42.5"|float == 42.5 }} -> true
format #
Apply the given values to a printf-style format string.
{{ "%s, %s!"|format(greeting, name) }}
-> Hello, World!
int #
Converts a value into an integer.
{{ "42"|int == 42 }} -> true
join #
Joins a sequence by a character
{{ "Foo Bar Baz" | join(", ") }} -> foo, bar, baz
length #
Returns the “length” of the value
By default this filter is also registered under the alias count.
Search results: {{ results|length }}
lower #
Converts a value to lowercase.
{{ "LOWERCASE!"|lower }} -> lowercase!
max #
Returns the largest item from an iterable.
{{ [1, 2, 3, 4]|max }} -> 4
min #
Returns the smallest item from an iterable.
{{ [1, 2, 3, 4]|min }} -> 1
pluralize #
Returns a plural suffix if the value is not 1, ‘1’, or an object of length 1.
By default, the plural suffix is ‘s’ and the singular suffix is empty (‘’). You can specify a singular suffix as the first argument (or None, for the default). You can specify a plural suffix as the second argument (or None, for the default).
{{ users|length }} user{{ users|pluralize }}.
{{ entities|length }} entit{{ entities|pluralize("y", "ies") }}.
{{ platypuses|length }} platypus{{ platypuses|pluralize(None, "es") }}.
random #
Chooses a random element from a sequence or string.
{{user.name}} is {{ ["quiet", "cool", "kind", "funny"]|random }} -> PhasecoreX is cool
replace #
Does a string replace.
It replaces all occurrences of the first parameter with the second.
{{ "Hello World"|replace("Hello", "Goodbye") }}
-> Goodbye World
split #
Split a string into its substrings, using split as the separator string.
If split is not provided or none the string is split at all whitespace characters and multiple spaces and empty strings will be removed from the result.
The maxsplits parameter defines the maximum number of splits (starting from the left). Note that this follows Python conventions rather than Rust ones so 1 means one split and two resulting items.
{{ "hello world"|split|list }}
-> ["hello", "world"]
{{ "c,s,v"|split(",")|list }}
-> ["c", "s", "v"]
title #
Converts a value to title case.
{{ "unreal tournament"|title }} -> "Unreal Tournament"
trim #
Trims a string.
By default, it trims leading and trailing whitespaces:
{{ " non-space characters " | trim }} -> "non-space characters"
You can also remove a character sequence. All the prefixes and suffixes matching the sequence are removed:
{{ "1212foo12bar1212" | trim("12") }} -> "foo12bar"
upper #
Converts a value to uppercase.
{{ user.name|upper }}
Examples #
AutoRoom Names #
{{user.name}}'s Room
{% if user.game %}
{{user.game}}
{% else %}
{{user.name}}'s Room
{% endif %}
{{user.name}}'s {{ ["Room", "Hangout", "Club", "Castle", "Circle", "Friends"]|random }}
AutoRoom Introduction Messages #
Hey {{user.mention}}! Welcome to your AutoRoom!
You created this AutoRoom from the AutoRoom Source {{source.mention}}.
This AutoRoom is named {{autoroom.mention}}.
Enjoy!