# utils-liquid

> This library was generated with [Nx](https://nx.dev).

Latest version **0.0.3** (published 2023-05-24) · 0 weekly downloads

## Install

```sh
npm install utils-liquid
pnpm add utils-liquid
yarn add utils-liquid
bun add utils-liquid
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2023-05-24 |
| First published | 2023-05-24 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 23.7 KB |
| Known vulnerabilities | 0 (+18 in 1 direct dependencies) |
| Install scripts | no |
| Maintainers | apim-dev |

## Links

- npm: https://www.npmjs.com/package/utils-liquid
- npm.io page: https://npm.io/package/utils-liquid

## Dependencies (3)

- [tslib](https://npm.io/package/tslib.md) 2.5.0
- [liquidjs](https://npm.io/package/liquidjs.md) 3.1.3
- [js-base64](https://npm.io/package/js-base64.md) 2.6.4

## Recent versions

- 0.0.3 (latest) — 2023-05-24
- 0.0.2 — 2023-05-24
- 0.0.1 — 2023-05-24

## README

# utils-liquid

This library was generated with [Nx](https://nx.dev).

## Building

Run `nx build utils-liquid` to build the library.

## Use

Import library `imoprt { LiquidJS } from "utils-liquid"`

## Testing
Following are the examples to test with jest 

```js
import { LiquidJS } from 'utils-liquid';

describe('compiles liquid templates', () => {
  const liquid = new LiquidJS();
  it('parses simple template', () => {
    const parsed = liquid.parse('123 {{foo}}');
    expect(parsed).toBeDefined();
  });

  it('renders simple template', async () => {
    const parsed = liquid.parse('123 {{foo}}');
    expect(await liquid.render(parsed, { foo: 'wowow' })).toEqual('123 wowow');
  });

  it('renders with json filter', async () => {
    const parsed = liquid.parse('123 {{foo | json}}');
    expect(await liquid.render(parsed, { foo: { val: true } })).toEqual(
      '123 {"val":true}'
    );
    const parsed1 = liquid.parse('123 {{foo | json: 2}}');
    expect(await liquid.render(parsed1, { foo: { val: true } })).toEqual(
      '123 {\n  "val": true\n}'
    );
  });

  it('renders with get_file_from_data_url filter', async () => {
    const parsed = liquid.parse('123 {{foo | get_file_from_data_url}}');
    expect(await liquid.render(parsed, { foo: 'data:;name=wow.txt;' })).toEqual(
      '123 wow.txt'
    );
    expect(await liquid.render(parsed, { foo: 'broken' })).toEqual('123 ');
  });

  it('renders with base64_encode filter', async () => {
    const parsed = liquid.parse('123 {{foo | base64_encode}}');
    expect(await liquid.render(parsed, { foo: 'hello world' })).toEqual(
      '123 aGVsbG8gd29ybGQ='
    );
  });
});

```

---
_Source: https://npm.io/package/utils-liquid · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
