liquidless
Advanced tools
Comparing version 1.3.3 to 1.3.4
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -8,2 +31,3 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
const json5_1 = __importDefault(require("json5")); | ||
const crypto = __importStar(require("crypto")); | ||
exports.defaultFilters = { | ||
@@ -16,5 +40,48 @@ upcase: (value) => value.toUpperCase(), | ||
toString: (value) => value.toString(), | ||
append: (value, args) => value.concat(...args), | ||
base64_decode: (value) => atob(value), | ||
base64_encode: (value) => btoa(value), | ||
camelize: (value) => value.replace(/[_.-](\w|$)/g, (_, x) => x.toUpperCase()), | ||
escape: (value) => value.replace(/[&"'<>]/g, c => htmlEscapeLookup.get(c)), | ||
hmac_sha1: (value) => crypto.createHash("sha1").update(value).digest("hex"), | ||
hmac_sha256: (value) => crypto.createHash("sha256").update(value).digest("hex"), | ||
lstrip: (value) => value.trimStart(), | ||
md5: (value) => crypto.createHash("md5").update(value).digest("hex"), | ||
newline_to_br: (value) => value.replace(/\n/g, '<br/>'), | ||
pluralize: (value, args) => value.toString().concat(' ', parseInt(value) === 1 ? args[0] : args[1]), | ||
prepend: (value, args) => args[0].toString().concat(value), | ||
remove: (value, args) => value.replaceAll(args[0], ''), | ||
remove_first: (value, args) => replace_first(value, args[0], ''), | ||
remove_last: (value, args) => replace_last(value, args[0], ''), | ||
replace: (value, args) => value.replaceAll(args[0], args[1]), | ||
replace_first: (value, args) => replace_first(value, args[0], args[1]), | ||
replace_last: (value, args) => replace_last(value, args[0], args[1]), | ||
rstrip: (value) => value.trimEnd(), | ||
sha1: (value) => crypto.createHash("sha1").update(value).digest("hex"), | ||
sha256: (value) => crypto.createHash("sha256").update(value).digest("hex"), | ||
slice: (value, args) => Array.isArray(value) ? value.slice(args[0], args[1]) : value.toString().slice(args[0], args[1]), | ||
split: (value, args) => value.toString().split(args[0]), | ||
strip: (value) => value.trim(), | ||
strip_newlines: (value) => value.replace(/[\r\n]/g, ''), | ||
strip_html: (value) => value.toString().replace(/<[^>]+>/g, ''), | ||
url_encode: (value) => encodeURIComponent(value), | ||
url_decode: (value) => decodeURIComponent(value), | ||
}; | ||
const QUOTED_STRING_REGEX = /^(["'])(?<string>.+)\1$/; | ||
const splitPattern = /,(?![^{}]*})/g; | ||
const htmlEscapeLookup = new Map([ | ||
['&', '&'], | ||
['"', '"'], | ||
['\'', '''], | ||
['<', '<'], | ||
['>', '>'], | ||
]); | ||
function replace_first(str, substr, newstr) { | ||
const pos = str.indexOf(substr); | ||
return pos < 0 ? str : str.substring(0, pos) + newstr + str.substring(pos + substr.length); | ||
} | ||
function replace_last(str, substr, newstr) { | ||
const pos = str.lastIndexOf(substr); | ||
return pos < 0 ? str : str.substring(0, pos) + newstr + str.substring(pos + substr.length); | ||
} | ||
const parseArgs = (args) => args.length > 0 | ||
@@ -21,0 +88,0 @@ ? args |
{ | ||
"name": "liquidless", | ||
"version": "1.3.3", | ||
"version": "1.3.4", | ||
"description": "Shopify's Liquid template engine, but less powerful", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -76,6 +76,35 @@ # liquidless | ||
- `upcase` - converts each character of a string to uppercase | ||
- `downcase` - each character of a string to lowercase | ||
- `toInt` - converts a value to Int | ||
- `toFloat` - converts a value to Float | ||
- `toString` - converts a value to String | ||
- `append` - Adds a given string to the end of a string. | ||
- `base64_decode` - Decodes a string in Base64 format. | ||
- `base64_encode` - Encodes a string to Base64 format. | ||
- `camelize` - Converts a string to CamelCase. | ||
- `capitalize` - Capitalizes the first word in a string and downcases the remaining characters. | ||
- `downcase` - Converts a string to all lowercase characters. | ||
- `escape` - Escapes special characters in HTML, such as `<>`, ', and `&`, and converts characters into escape sequences. | ||
- `hmac_sha1` - Converts a string into an SHA-1 hash using a hash message authentication code (HMAC). | ||
- `hmac_sha256` - Converts a string into an SHA-256 hash using a hash message authentication code (HMAC). | ||
- `lstrip` - Strips all whitespace from the left of a string. | ||
- `md5` - Converts a string into an MD5 hash. | ||
- `newline_to_br` - Converts newlines (`\n`) in a string to HTML line breaks (`<br>`). | ||
- `pluralize` - Outputs the singular or plural version of a string based on a given number. | ||
- `prepend` - Adds a given string to the beginning of a string. | ||
- `remove` - Removes any instance of a substring inside a string. | ||
- `remove_first` - Removes the first instance of a substring inside a string. | ||
- `remove_last` - Removes the last instance of a substring inside a string. | ||
- `replace` - Replaces any instance of a substring inside a string with a given string. | ||
- `replace_first` - Replaces the first instance of a substring inside a string with a given string. | ||
- `replace_last` - Replaces the last instance of a substring inside a string with a given string. | ||
- `rstrip` - Strips all whitespace from the right of a string. | ||
- `sha1` - Converts a string into an SHA-1 hash using a hash message authentication code (HMAC). | ||
- `sha256` - Converts a string into an SHA-256 hash using a hash message authentication code (HMAC). | ||
- `slice` - Returns a substring or series of array items, starting at a given 0-based index. | ||
- `split` - Splits a string into an array of substrings based on a given separator. | ||
- `strip` - Strips all whitespace from the left and right of a string. | ||
- `strip_html` - Strips all HTML tags from a string. | ||
- `strip_newlines` - Strips all newline characters (line breaks) from a string. | ||
- `toInt` - Converts a value to Int | ||
- `toFloat` - Converts a value to Float | ||
- `toString` - Converts a value to String | ||
- `upcase` - Converts a string to all uppercase characters. | ||
- `url_decode` - Decodes a string to URL-safe format by converting percent-encoded characters to special characters. | ||
- `url_encode` - Encodes a string to URL-safe format by converting special characters to percent-encoded characters. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13341
163
110