Skip to main content

Crate brrrty_js

Crate brrrty_js 

Source
Expand description

JavaScript-like runtime values shared by Brrrty’s template engines.

Re-exports§

pub use tz::Tz;

Modules§

clock
The current time, which SOURCE_DATE_EPOCH can freeze.
functions
Calling functions from JavaScript data while a page is built.
locale
Node’s default locale, which toLocaleString() and localeCompare() use when they’re given none.
runtime
What crosses from a JavaScript runtime (the site’s own Node, run by brrrty-node) into a build: decoded values, function handles, errors, and the trait a build drives the runtime through.
traps
Reads Brrrty can’t answer from the data alone, noticed while a template renders.
tz
Time zones as JavaScript sees them: broken-down time, the offset, the zone’s id and its long name.

Structs§

FilterEnv
What an engine-neutral filter can see of the build and of the call.
FnHandle
A function value that stayed in the JavaScript runtime, to be called later.
LoadError
Why a Loader could not supply a template.

Enums§

CollationRefusal
Why a pair of strings isn’t compared.
Value
A JavaScript-like value. Objects keep their insertion order.

Constants§

REFUSAL_PREFIX
A filter’s error that starts with this is a refusal: the filter can’t do what was asked exactly, as opposed to the call failing as it would in JavaScript. Nunjucks reports it as unsupported.

Traits§

Loader
Finds included templates by name. Returns the resolved path and the source.

Functions§

array_index
key as an array index, if it is one written canonically: "7" but not "07", "-1" or "4294967295".
console_format
What console.log(...values) prints: strings as they are, other values as util.inspect shows them, joined by spaces. Format specifiers such as %s are not interpreted, and nested values print in the single-line form Node uses when they fit in 80 columns.
eleventy_filters
Eleventy’s filters, by name.
is_js_whitespace
JavaScript’s whitespace and line terminators: what \s matches in a regular expression, and what Number(text) and trim() remove.
js_locale_compare
a.localeCompare(b) in Node with an English locale (en-US, or C): less, equal or greater, as its -1, 0 or 1. Err names a character whose order in Node can’t be matched.
js_number_to_string
Formats n exactly as JavaScript’s String(n) does.
js_string_to_number
JavaScript’s Number(text).
js_to_fixed
Number.prototype.toFixed(digits), as V8 does it.
js_to_locale_string
n.toLocaleString('en-US') with no options, as Node’s ICU prints it: the shortest digits that read back as n (those String(n) uses), rounded half away from zero to at most 3 decimals, trailing zeros dropped, and the whole part in groups of three with ,. -0 (and a negative number that rounds to zero) keeps its -; infinity is ∞.
slugify
@sindresorhus/slugify 2.2.1 with { decamelize: false }: 11ty’s slugify filter.

Type Aliases§

FilterFn
A filter that a template engine can call: the closure form of FilterImpl, for filters that carry state, such as one written in a config script.
FilterImpl
A filter that does not depend on a template engine.