1.0.3 • Published 2 years ago

liquidjs-lite v1.0.3

Weekly downloads
-
License
MPL-2.0
Repository
github
Last release
2 years ago

liquidjs-lite

Shopify's Liquid template engine, but less powerful. Perfect for configuration files

Get Started

Install the dependency from npm:

npm i liquidjs-lite

Import the renderTemplate function

import { renderTemplate } from 'liquidjs-lite'

Usage

Example: Rendering a string

renderTemplate('Hello, {{ world }}', { world: 'world!' }

Outputs:

Hello, world!

Example: Using filters

renderTemplate('Hello, {{ world | upcase }}', { world: 'world!' }

Outputs:

Hello, WORLD!

Example: Supplying custom filters

renderTemplate('Hello, {{ world | something 1, 2, 3 }}', { world: 'world!' }, {
  filters: {
    something: (value, args) => `${value} ${args.join(', ')}`
  }
})

Outputs:

Hello, world 1, 2, 3!

Example: Rending values in an object

renderTemplate([{'hello': {'world': '{{ world }}'}}], { world: 'world!' })

Outputs

[ { hello: { world: 'world!' } } ]

Filters

  • upcase, converts each character of a string to uppercase
1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago