daniel-nemeth / subplur
Substitute & Pluralize for JavaScript and jQuery
1.0.0
2018-12-29 14:51 UTC
Requires
- contao-components/installer: ^1.0.9
- daniel-nemeth/jqclass: 1.*
This package is not auto-updated.
Last update: 2025-03-03 02:38:01 UTC
README
Substitute & Pluralize for JavaScript and jQuery. This is an contao-component.
Usage
var subplur = new dnSubPlur();
// Substitute
var string = 'This is an [example] for substitute.';
subplur.substitute(string, {example: 'test'}); // or with jQuery
$.substitute(string, {example: 'test'});
// Pluralize
var string = 'There {are|is} [num] apple{s} on the tree.';
subplur.pluralize(string, 1); // There is 1 apple on the tree.
$.pluralize(string, 1);
subplur.pluralize(string, 3); // There are 3 apples on the tree.
$.pluralize(string, 3);
// Substitute & Pluralize
var string = 'There {are|is} [num] [apple]{s} on the tree.';
subplur.subplur(string, 1, {apple: 'banana'}); // There is 1 banana on the tree.
$.subplur(string, 1, {apple: 'banana'});
subplur.subplur(string, 3, {apple: 'banana'}); // There are 3 bananas on the tree.
$.subplur(string, 3, {apple: 'banana'});