@ribajs/core
Version:
Core module of Riba.js
19 lines (17 loc) • 496 B
text/typescript
import { Formatter } from "../../types/index.js";
import { handleize } from "@ribajs/utils/src/type.js";
/**
* Formats a string into a handle.
* E.g. '100% M & Ms!!!' -> 100-m-ms
* @see https://help.shopify.com/themes/liquid/filters/string-filters#handle-handleize
*/
export const handleizeFormatter: Formatter = {
name: "handleize",
read(str: string) {
if (!str) {
console.warn("[handleizeFormatter] str is not set");
return "";
}
return handleize(str);
},
};