Do you need more handlebars helpers in Foundry VTT?
This is the Foundry Module for you!
Helpers that are included in this module:
abs
add
avg
ceil
divide
floor
gt
gte
lt
lte
modulo
multiply
random
regexp
replace
replaceAll
round
sanitize
split
subtract
sum
table
- Need More Helpers?
- Supporting this Module
Return the magnitude of a
.
num
{number}
Return the sum of a
plus b
.
a
{number}b
{number}
Returns the average of all numbers in the given array.
...args
{numbers}: one or more number arguments
Get the Math.ceil()
of the given value.
a
{number}
Divide a
by b
a
{number}: numeratorb
{number}: denominator
Get the Math.floor()
of the given value.
value
{number}
Test whether a value is greater than another value.
a
{any}: the value to testb
{any}: the value to test against
Test whether a value is greater than or equal to another value.
a
{any}: the value to testb
{any}: the value to test against
Test whether a value is less than another value.
a
{any}: the value to testb
{any}: the value to test against
Test whether a value is less than or equal to another value.
a
{any}: the value to testb
{any}: the value to test against
Get the remainder of a division operation.
a
{number}: numeratorb
{number}: denominator
Return the product of a
times b
.
a
{number}: factorb
{number}: multiplier
Generate a random integer between two values, including the min and max values.
min
{number}max
{number}
Converts text
into a RegExp
instance to be fed into other helpers.
text
{string}flags
(optional, default"g"
) {string}: flags to use when creating the instance ofRegExp
.
Replace first instance of searchTextOrRegExp
with replacementText
in text
.
text
{string}searchTextOrRegExp
{string}: the text to be replaced, or an instance ofRegExp
(see regexp)replacementText
{string}: the text to replacesearchTextOrRegExp
; it follows the rules ofString.prototype.replace()
, soRegExp
replacements can replace multiple results while a regular string of text will be replaced once
Replace all instances of searchTextOrRegExp
with replacementText
in text
.
text
{string}searchTextOrRegExp
{string}: the text to be replaced, or an instance ofRegExp
(see regexp)replacementText
{string}: the text to replacesearchTextOrRegExp
throughouttext
Round the given number.
number
{number}
Strip HTML tags from a string, so that only the text is preserved.
htmlString
{string}: The string of HTML to sanitize.
Split string by the given character.
text
{string}separator
{string}: The pattern describing where each split should occur
Return the difference of a
minus b
.
a
{number}: left termb
{number}: right right
Returns the sum of all numbers in the given array.
...args
{numbers}: two or more number arguments
Look up a value in a static look-up table and replace it with another value.
lookup
{string}: the text to use as a lookup keykey1
{string}: the key forresult1
; can contain a regular expressionresult1
{string}: the value to return whenlookup
matcheskey1
; can contain capturing groups (e.g. $1) to copy information from the matching regex keykey2
,result2
,key3
,result3
, etc.
We want to look up what "blue" means, according to a static series of keys and results.
We want to look up what "blue" means, according to a static series of keys and results. The blue
key uses regex to capture the key, and its value references the key via $1
.
- Open an issue.
- Optional: submit a pull request to resolve the issue if you know how to do it and want to contribute.
I plan to keep building up this collection of helpers over time. If you like what I'm doing, feel free to send some support my way.