Skip to content

Latest commit

 

History

History
55 lines (40 loc) · 2.86 KB

liquid.md

File metadata and controls

55 lines (40 loc) · 2.86 KB

Liquid

Eleventy Short Name File Extension NPM Package
liquid .liquid liquidjs

You can override a .liquid file’s template engine. Read more at Changing a Template’s Rendering Engine.

Library Options

Defaults

Rather than constantly fixing outdated documentation, find getLiquidOptions in Liquid.js. These options are different than the default liquidjs options.

Use your own options

New in Eleventy v0.2.15: It’s recommended to use the Configuration API to set override the default options above.

module.exports = function(eleventyConfig) {
  eleventyConfig.setLiquidOptions({
    dynamicPartials: true
  });
};

Set your own Library instance

New in Eleventy v0.3.0: As an escape mechanism for advanced usage, pass in your own instance of the Liquid library using the Configuration API. See all liquidjs options.

⚠️ Not compatible with setLiquidOptions above—this method will ignore any configuration set there.

module.exports = function(eleventyConfig) {
  let liquidJs = require("liquidjs");
  let options = {
    extname: ".liquid",
    dynamicPartials: true,
    root: ["_includes"]
  };

  eleventyConfig.setLibrary("liquid", liquidJs(options));
};

Supported Features

Feature Syntax
✅ Include {% include 'user' %} looks for _includes/user.liquid
✅ Include (pass in Data) {% include 'user' with 'Ava' %}
✅ Include (pass in Data) {% include 'user', user1: 'Ava', user2: 'Bill' %}
✅ Custom Filters {{ name | upper }} (see eleventyConfig.addLiquidFilter documentation)
Eleventy Universal Filters {% name | filterName %} (see eleventyConfig.addFilter documentation)
✅ Custom Tags {% upper name %} (see eleventyConfig.addLiquidTag documentation)