Development is frozen. The published package, documentation, examples, and changelog remain available.
Permalink to InstallationInstallation
Permalink to Quick TakeQuick Take
Permalink to ExamplesExamples
- Inline conditional ordering is shared by Jinja and Nunjucks
- Detect Jinja namespace assignment syntax
- Find Jinja format filter markers, including whitespace around the call
Purpose
Find textual hints associated with Jinja namespace assignments and format filters. Nunjucks and Jinja share most syntax, and extensions can add similar functions or filters to other engines, so these matches do not prove an engine’s identity.
- Namespace assignment markers, such as
set ns = namespace (total=0). Thesetkeyword must be separate from the assigned name. This hint uses ASCII word characters for assignment names. - Format filter markers, such as
|format(or| format (. Whitespace around the filter name and opening parenthesis is accepted.
The regex searches substrings, including prose, quoted text, comments, and invalid format expressions. It does not parse template tokens or validate printf strings. Use detect-templating-language for refinement based on live template syntax.
Inline if expressions are shared syntax and are excluded as Jinja-specific evidence. Nunjucks supports inline conditionals, including an optional else.
API — isJinjaSpecific()
The main function isJinjaSpecific() is imported like this:
Returns a fresh global, case-insensitive RegExp, /.../gi. Use it with RegExp.prototype.exec() or String.prototype.match(). Create a fresh regex for independent .test() calls, or reset lastIndex to zero.
Formatting matches now contain the filter marker itself. The earlier pattern included the preceding quoted numeric format string:
const input = '"%.2f"|format(price)';
// Earlier match: ['"%.2f"|format(']
input.match(isJinjaSpecific()); // ["|format("]
Whitespace within the marker is preserved in each match. For example, "%s" | format (name) produces | format (.
API — version
You can import version: