From 55385af686d078997e3dde19bc4927a4a4a453bd Mon Sep 17 00:00:00 2001 From: dpiercey Date: Wed, 9 Oct 2024 13:20:20 -0700 Subject: [PATCH] fix: add back marko v3 legacy helpers --- .changeset/sour-carrots-ring.md | 5 +++++ packages/marko/helpers/README.md | 3 +++ packages/marko/helpers/empty.js | 4 ++++ packages/marko/helpers/notEmpty.js | 11 +++++++++++ 4 files changed, 23 insertions(+) create mode 100644 .changeset/sour-carrots-ring.md create mode 100644 packages/marko/helpers/README.md create mode 100644 packages/marko/helpers/empty.js create mode 100644 packages/marko/helpers/notEmpty.js diff --git a/.changeset/sour-carrots-ring.md b/.changeset/sour-carrots-ring.md new file mode 100644 index 000000000..29e5c4ee0 --- /dev/null +++ b/.changeset/sour-carrots-ring.md @@ -0,0 +1,5 @@ +--- +"marko": patch +--- + +Add back the "legacy helpers" from Marko 3 to simplify the process of upgrading some older applications. diff --git a/packages/marko/helpers/README.md b/packages/marko/helpers/README.md new file mode 100644 index 000000000..05552bdd3 --- /dev/null +++ b/packages/marko/helpers/README.md @@ -0,0 +1,3 @@ +# Marko Helpers + +This directory contains helpers that were deprecated in Marko v3. Marko v4/5 no longer adds these helpers to every compiled template, but you can still import them if needed. diff --git a/packages/marko/helpers/empty.js b/packages/marko/helpers/empty.js new file mode 100644 index 000000000..73f1f1061 --- /dev/null +++ b/packages/marko/helpers/empty.js @@ -0,0 +1,4 @@ +var notEmpty = require("./notEmpty"); +module.exports = function empty(o) { + return !notEmpty(o); +}; diff --git a/packages/marko/helpers/notEmpty.js b/packages/marko/helpers/notEmpty.js new file mode 100644 index 000000000..d07297f1f --- /dev/null +++ b/packages/marko/helpers/notEmpty.js @@ -0,0 +1,11 @@ +module.exports = function (o) { + if (o == null) { + return false; + } else if (Array.isArray(o)) { + return !!o.length; + } else if (o === "") { + return false; + } + + return true; +};