All Projects → cobalt-org → Liquid Rust

cobalt-org / Liquid Rust

Licence: mit
Liquid templating for Rust

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to Liquid Rust

Fhir Converter
Conversion utility to translate legacy data formats into FHIR
Stars: ✭ 123 (-46.29%)
Mutual labels:  liquid
Eval
Eval is a lightweight interpreter framework written in Swift, evaluating expressions at runtime
Stars: ✭ 157 (-31.44%)
Mutual labels:  template-language
Milk
Milk is Mustache in CoffeeScript -- great with your browser or NodeJS!
Stars: ✭ 192 (-16.16%)
Mutual labels:  template-language
Jekyll Timeago
⌛️ Ruby library to compute distance of dates in words. Originally built for Jekyll.
Stars: ✭ 130 (-43.23%)
Mutual labels:  liquid
Skeleton Theme
A barebones ☠️starter theme with the required files needed to compile with Slate and upload to Shopify.
Stars: ✭ 153 (-33.19%)
Mutual labels:  liquid
Pongo2
Django-syntax like template-engine for Go
Stars: ✭ 2,111 (+821.83%)
Mutual labels:  template-language
Jekyll Menus
A menus (site navigation) plugin for your Jekyll website that also works with https://forestry.io (Jekyll CMS)
Stars: ✭ 115 (-49.78%)
Mutual labels:  liquid
Htl Spec
HTML Template Language Specification
Stars: ✭ 213 (-6.99%)
Mutual labels:  template-language
Phptal
PHP Template Attribute Language — template engine for XSS-proof well-formed XHTML and HTML5 pages
Stars: ✭ 155 (-32.31%)
Mutual labels:  template-language
Bootstrapify 1
An open-source base theme for Shopify using Twitter Bootstrap
Stars: ✭ 189 (-17.47%)
Mutual labels:  liquid
Shopify Modern
A modern template for developing Shopify-themes using Vuejs
Stars: ✭ 136 (-40.61%)
Mutual labels:  liquid
Fleet
Templating System for Clojure
Stars: ✭ 148 (-35.37%)
Mutual labels:  template-language
Automad
A flat-file content management system and template engine
Stars: ✭ 163 (-28.82%)
Mutual labels:  template-language
Concrete
🏗 Concrete Shopify Theme Framework
Stars: ✭ 124 (-45.85%)
Mutual labels:  liquid
Init.nvim
An Opinionated Neovim Config for the Minimalists
Stars: ✭ 194 (-15.28%)
Mutual labels:  liquid
Vc Storefront
VirtoCommerce Storefront for ASP.NET Core 3.1 repository
Stars: ✭ 122 (-46.72%)
Mutual labels:  liquid
Ehtml
HTML Framework that allows you not to write JavaScript code.
Stars: ✭ 161 (-29.69%)
Mutual labels:  template-language
Htmlkit
A type-safe DSL that renders dynamic HTML templates in Swift
Stars: ✭ 229 (+0%)
Mutual labels:  template-language
Slang
Slim-inspired templating language for Crystal
Stars: ✭ 200 (-12.66%)
Mutual labels:  template-language
Smartstorenet
Open Source ASP.NET MVC Enterprise eCommerce Shopping Cart Solution
Stars: ✭ 2,363 (+931.88%)
Mutual labels:  liquid

liquid-rust

Liquid templating for Rust

Build Status Crates Status Dependency Status

Goals:

  1. Conformant. Incompatibilities with strict shopify/liquid are bugs to be fixed.
  2. Flexible. Liquid embraces variants for different domains and we want to follow in that spirit.
  3. Performant. Do the best we can within what is conformant.

Example applications using liquid-rust:

Usage

To include liquid in your project add the following to your Cargo.toml:

[dependencies]
liquid = "0.20"

Example:

let template = liquid::ParserBuilder::with_stdlib()
    .build().unwrap()
    .parse("Liquid! {{num | minus: 2}}").unwrap();

let mut globals = liquid::object!({
    "num": 4f64
});

let output = template.render(&globals).unwrap();
assert_eq!(output, "Liquid! 2".to_string());

You can find a reference on Liquid syntax here.

Customizing Liquid

Language Variants

By default, liquid-rust has no filters, tags, or blocks. You can enable the default set or pick and choose which to add to suite your application.

Create your own filters

Creating your own filters is very easy. Filters are simply functions or closures that take an input Value and a Vec<Value> of optional arguments and return a Value to be rendered or consumed by chained filters.

See filters.rs for what a filter implementation looks like. You can then register it by calling liquid::ParserBuilder::filter.

Create your own tags

Tags are made up of two parts, the initialization and the rendering.

Initialization happens when the parser hits a Liquid tag that has your designated name. You will have to specify a function or closure that will then return a Renderable object to do the rendering.

See include_tag.rs for what a tag implementation looks like. You can then register it by calling liquid::ParserBuilder::tag.

Create your own tag blocks

Blocks work very similar to Tags. The only difference is that blocks contain other markup, which is why block initialization functions take another argument, a list of Elements that are inside the specified block.

See comment_block.rs for what a block implementation looks like. You can then register it by calling liquid::ParserBuilder::block.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].