@airelogic/liquidjs-extensions
v0.1.3
Published
A collection of custom filters for [Liquid.js](https://liquidjs.com/).
Readme
@airelogic/liquidjs-extensions
A collection of custom filters for Liquid.js.
Installation
npm install @airelogic/liquidjs-extensionsUsage
import { LiquidEngine } from '@airelogic/liquidjs-extensions';
const MyComponent = () => {
// ... component logic
function getFormatted () {
const template = LiquidEngine.parse("{{ value | round_to_next: 'month' }}");
return dateTimeInput => `${LiquidEngine.renderSync(template, { value: dateTimeInput })}`;
}
// ... rest of your component
};Filters:
cui_date_time
- Takes an ISO datetime and formats as
dd-MMM-yyy HH:mm
cui_date
- Takes an ISO date and formats as
dd-MMM-yyy
cui_time
- Takes an ISO time and formats as
HH:mm
plus_time
- Takes an ISO datetime and updates the date per the arguments
- Needs at least one argument
- Choices are as follows:
- months
- weeks
- days
- hours
- minutes
{{ '2020-10-05T12:34:56.0000000Z' | plus_time: months: 1, weeks: 2, days: 1, hours: 2, minutes: 10 }}
Also, accepts now or today as a shorthand for accepting the current date/time, if Now delegate has been furnished in the TemplateOptions{{ 'now' | plus_time: months: 1, weeks: 2, days: 1, hours: 2, minutes: 10 }}{{ 'today' | plus_time: months: 1, weeks: 2, days: 1, hours: 2, minutes: 10 }}
round_to_next
- Takes an ISO datetime and rounds the date per the argument
- Takes one argument per filter
- Choices are as follows:
- month
- weekday
- hour
- monday/tuesday/wednesday/thursday/friday/saturday or sunday
{{ 'now' | round_to_next: 'month' }}
{{ 'today' | round_to_next: 'month' }}
{{ '2023-05-27 12:34:56 -04:00' | round_to_next: 'month' }}
age
- Takes an ISO datetime and computes the age per the argument
- Takes one argument per filter
- Choices are as follows:
- year
- month
- week
- day
- hour
- minute
{{ '2020-10-05T12:34:56.0000000Z' | age: 'minute' }}
License
This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.
