regex-is-jinja-nunjucks3.0.1

Regular expression for detecting Jinja or Nunjucks code

Quick Take

import { strict as assert } from "assert";
import { isJinjaNunjucksRegex } from "regex-is-jinja-nunjucks";

// detects Jinja/Nunjucks code
assert.equal(
  isJinjaNunjucksRegex().test(
    `<div>{% if data.purchases.count > 1 %}these{% else %}this{% endif %}</div>`
  ),
  true
);

// in case if it's not nunjucks
assert.equal(
  isJinjaNunjucksRegex().test(`<div>tralala</div>`),
  false
);

API

isJinjaNunjucksRegex()

In other words, it's a function which returns a RegExp object.

Changelog

See it in the monorepo opens in a new tab, on GitHub.

Contributing

To report bugs or request features or assistance, raise an issue on GitHub opens in a new tab.

Any code contributions welcome! All Pull Requests will be dealt promptly.

Licence

MIT opens in a new tab

Copyright © 2010–2021 Roy Revelt and other contributors

Related packages:

📦 detect-templating-language 3.0.1
Detects various templating languages present in string
📦 stristri 4.0.1
Extracts or deletes HTML, CSS, text and/or templating tags from string
📦 regex-is-jsp 3.0.1
Regular expression for detecting JSP (Java Server Pages) code
📦 regex-jinja-specific 3.0.1
Regular expression for detecting Python-specific Jinja code
📦 regex-empty-conditional-comments 2.0.1
Regular expression for matching HTML empty conditional comments