-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
db6844e
commit 284885d
Showing
2 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* Handlebars Comparaison Helpers | ||
* | ||
* @source https://github.com/helpers/handlebars-helpers | ||
* | ||
* @package kzarshenas/crazyphp | ||
* @author kekefreedog <[email protected]> | ||
* @copyright 2022-2024 Kévin Zarshenas | ||
*/ | ||
|
||
/** | ||
* Is | ||
* | ||
* Block helper that renders a block if a is equal to b. | ||
* If an inverse block is specified it will be rendered when falsy. | ||
* Similar to eq but does not do strict equality. | ||
* | ||
* @param a Value to compare | ||
* @param v Value to compare with | ||
* | ||
* @return boolean | ||
*/ | ||
module.exports = (index, list, options) => ( | ||
typeof index === "number" && | ||
( | ||
( | ||
Array.isArray(list) && | ||
index === (list.length - 1) | ||
) || | ||
( | ||
typeof list === "object" && | ||
index === (Object.keys(list).length - 1) | ||
) | ||
) | ||
) | ||
? options.fn(this) | ||
: options.inverse(this) | ||
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters