Skip to content

Case conversion (CamelCase, snake_case, ...) filters for Liquid using Heck library.

Notifications You must be signed in to change notification settings

djedi23/liquid-heck

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

liquid-heck

Case conversion (CamelCase, snake_case, ...) filters for Liquid using Heck library.

This library provides case conversion filters for the Liquid template engine, utilizing the Heck library for case conversion.

... in filter() ... in templates
KebabCase kebabcase
LowerCamelCase lowercamelcase
ShoutyKebabCase shoutykebabcase
ShoutySnakeCase shoutysnakecase
SnakeCase snakecase
TitleCase titlecase
TrainCase traincase
UpperCamelCase uppercamelcase

Example

To use the case conversion filters in your Liquid templates, you first need to register the filters.

use liquid_heck::{UpperCamelCase,SnakeCase,TrainCase};

let template = liquid::ParserBuilder::with_stdlib()
    .filter(UpperCamelCase)	// Register the filters
    .filter(SnakeCase)
    .filter(TrainCase)
    .build().unwrap()
    .parse("{{text | uppercamelcase}} {{text | snakecase}} {{text | traincase}}").unwrap();

let mut globals = liquid::object!({
    "text": "Some text to convert"
});

let output = template.render(&globals).unwrap();
assert_eq!(output, "SomeTextToConvert some_text_to_convert Some-Text-To-Convert".to_string());

About

Case conversion (CamelCase, snake_case, ...) filters for Liquid using Heck library.

Resources

Stars

Watchers

Forks

Packages

No packages published