detect-templating-language examples

Table of Contents

Quick Take

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

// detects Nunjucks
assert.deepEqual(
  detectLang(
    `<div>{% if something %}x{% else %}y{% endif %}</div>`
  ),
  { name: "Nunjucks" }
);

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