liquid
Version, currently 0.3.27 versions
github.com/dare892/liquid.cr
Kind of liquid template engine for Crystal [WIP]
Nothing has been indexed for 0.3.2 yet. The tag is recorded, its shard.yml has not been read, so the manifest and dependency list below are empty because they are unknown rather than because they are absent.
Installation
# Add this to your shard.yml
dependencies:
liquid:
github: dare892/liquid.cr
version: ~> 0.3.2Then run:
shards installshard.yml
No shard.yml has been indexed for 0.3.2. You can read it on the repository.
Dependencies
Unknown: the shard.yml for this version has not been read yet.
README
This README is the one indexed from the repository at its latest ref, not from the tag for this version.
liquid
Liquid template engine for Crystal.
Liquid templating language : http://shopify.github.io/liquid/
Installation
Add this to your application's shard.yml:
dependencies:
liquid:
github: TechMagister/liquid.cr
Usage
require "liquid"
txt = "
{% if kenny.sick %}
Kenny is sick.
{% elsif kenny.dead %}
You killed Kenny! You ***!!!
{% else %}
Kenny looks okay --- so far
{% endif %}
"
ctx = Liquid::Context.new
ctx.set "kenny", { "sick" => false, "dead" => true}
tpl = Liquid::Template.parse txt # tpl can be cached and reused
result = tpl.render ctx
# result = "
# You killed Kenny! You ***!!!
#
# "
Tags can be escaped:
\{% assign myvar = 15 %}
# or
{% raw %}
{% assign myvar = 15 %}
{% endraw %}
will both render {% assign myvar = 15 %}.
Blocks
Cache block (only supports caching using Redis): https://github.com/TechMagister/liquid-cache.cr
Filters
- [x] abs
- [x] append
- [x] camelcase | camelize
- [x] capitalize
- [x] ceil
- [x] compact
- [x] date
- [x] default
- [x] divided_by
- [x] downcase
- [x] escape
- [x] escape_once
- [x] first
- [x] floor
- [x] join
- [x] last
- [x] lstrip
- [x] map
- [x] minus
- [x] modulo
- [x] newline_to_br
- [x] pluralize
- [x] plus
- [x] prepend
- [x] remove
- [x] remove_first
- [x] replace
- [x] replace_first
- [x] reverse
- [x] round
- [x] rstrip
- [x] size
- [x] slice
- [ ] sort
- [ ] sort_natural
- [x] split
- [x] strip
- [x] strip_html
- [x] strip_newlines
- [ ] times
- [ ] truncate
- [ ] truncatewords
- [x] underscore
- [ ] uniq
- [x] upcase | uppercase
Development
TODO:
- [x] Basic For loops
- [x] Basic If Elsif Else
- [x] Raw and comment blocks ({% raw %} and {% comment %})
- [x] Add variable assignment ({% assign var = "Hello World" %})
- [x] Add support for multiple operator (no operator precedence support (for now))
- [x] Add support for Array into for loop
- [x] Add support for Hash into for loop ({% for key, val in myhash %})
- [x] Add support for Float
- [x] Add iteration over Arrays
- [x] Improve data interface
- [x] Add Filter support
- [x] Add capture block
- [x] Add increment block
- [x] Add decrement block
- [ ] Add "contains" keyword
- [ ] Add support for Array into expressions
- [ ] Add case/when
- [ ] Add syntax checking
- [ ] Improve expression parsing
- [ ] Add Everything that's missing [https://shopify.github.io/liquid/]
Contributing
- Fork it ( https://github.com/TechMagister/liquid.cr/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
Contributors
- TechMagister Arnaud Fernandés - creator, maintainer
- docelic Davor Ocelic
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
0.3.2- Tagged
- May 26, 2021
- Commit
6698a3898b93- Indexed
- not yet
Dependents
No indexed shard depends on this one yet.
Repository
github.com/dare892/liquid.cr
Metadata
- Created
- Aug 16, 2026
- Updated
- Aug 16, 2026
- Synced
- Aug 16, 2026
- Versions
- 7