Detects various templating languages present in string

Quick Take

import { strict as assert } from "assert";
import { detectLang } from "detect-templating-language";

// detects Nunjucks
    `<div>{% if something %}x{% else %}y{% endif %}</div>`
  { name: "Nunjucks" }

// detects JSP (Java Server Pages)
    `<div><c:set var="someList" value="\${jspProp.someList}" /></div>`
  { name: "JSP" }

Supported templating languages:

  • Nunjucks/Jinja/Liquid family
  • JSP (Java Server Pages)



In other words, it's a function which takes a string and returns a plain object.

API - Output

A plain object is returned, for example,

name: "Nunjucks"

If templating language is not detected, null is set:

name: null


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


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.


MIT opens in a new tab

Copyright © 2010–2021 Roy Revelt and other contributors

Related packages:

📦 regex-is-jsp 3.0.1
Regular expression for detecting JSP (Java Server Pages) code
📦 regex-is-jinja-nunjucks 3.0.1
Regular expression for detecting Jinja or Nunjucks code
📦 stristri 4.0.1
Extracts or deletes HTML, CSS, text and/or templating tags from string
📦 emlint 5.0.1
Pluggable email template code linter
📦 html-crush 5.0.1
Minifies HTML/CSS: valid or broken, pure or mixed with other languages
📦 string-strip-html 9.0.1
Strips HTML tags from strings. No parser, accepts mixed sources
📦 detect-is-it-html-or-xhtml 5.0.1
Answers, is the string input string more an HTML or XHTML (or neither)