# egg-view-liquid

> egg view plugin for liquidJs

Latest version **1.0.5** (published 2020-09-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install egg-view-liquid
pnpm add egg-view-liquid
yarn add egg-view-liquid
bun add egg-view-liquid
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2020-09-27 |
| First published | 2020-09-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=8.0.0 |
| Dependencies | 1 |
| Unpacked size | 11 KB |
| Known vulnerabilities | 0 (+18 in 1 direct dependencies) |
| Install scripts | no |
| Author | i7eo |
| Maintainers | i7eo |
| Keywords | egg, egg-plugin, egg-view, liquid |

## Links

- npm: https://www.npmjs.com/package/egg-view-liquid
- Repository: https://github.com/i7eo/egg-view-liquid
- Homepage: https://github.com/i7eo/egg-view-liquid#readme
- Issues: https://github.com/i7eo/egg-view-liquid/issues
- npm.io page: https://npm.io/package/egg-view-liquid

## Dependencies (1)

- [liquidjs](https://npm.io/package/liquidjs.md) ^9.15.0

## Recent versions

- 1.0.5 (latest) — 2020-09-27
- 1.0.4 — 2020-09-24
- 1.0.2 — 2020-09-24
- 1.0.1 — 2020-09-16
- 1.0.0 — 2020-09-14

## README

# egg-view-liquid

[![NPM version][npm-image]][npm-url]

[npm-image]: https://img.shields.io/npm/v/egg-view-liquid.svg
[npm-url]: https://npmjs.org/package/egg-view-liquid

egg view plugin for [liquid].

## :large_blue_circle: Internationalization

English | [中文文档](README_zh.md)

## Install

```bash
$ npm i egg-view-liquid --save
```

## Usage

```js
// {app_root}/config/plugin.js
exports.liquid = {
  enable: true,
  package: 'egg-view-liquid',
};

// {app_root}/config/config.default.js
exports.view = {
  mapping: {
    '.liquid': 'liquid',
  },
};

// liquid config
exports.liquid = {};
```

Create a liquid file

```js
// app/view/hello.liquid
hello {{ data }}
```

Render it

```js
// app/controller/render.js
exports.liquid = async ctx => {
  await ctx.render('hello.liquid', {
    data: 'world',
  });
};
```

The file will be compiled and cached, you can change `config.liquid.cache = false` to disable cache, it's disable in local env by default.

### Include

You can include both relative and absolute file.

Relative file is resolve from current file path.

```html
// app/view/a.liquid include app/view/b.liquid
{% render 'view/b' %}
```

Absolute file is resolve from `app/view`.

```html
// app/view/home.liquid include app/view/partial/menu.liquid
{% render 'partial/menu' %}
```

## Tips:

  1. Use when you need to import files: `partial/xxx` not `/partial/xxx`

  2. LiquidJs currently does not support direct use of method calls in files: `Hello {{helper.data()}}` can be replaced with tags or plugins if needed.

  3. Now, if you want to use LiquidJs for like express-ejs-Layout's `contentfor`, just use LiquidJs's `block` instead.

## Configuration

see [config/config.default.js](config/config.default.js) for more detail.

## Questions & Suggestions

Please open an issue [here](https://github.com/eggjs/egg/issues).


## :stuck_out_tongue_winking_eye: Authors

[i7eo](https://i7eo.com/about/)

## :copyright: License

[License MIT](LICENSE)

[liquid]: https://github.com/harttle/liquidjs

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