0.0
No commit activity in last 3 years
No release in over 3 years
ActiveRecord read queries in Liquid templates
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

Runtime

>= 4.0.0
 Project Readme

LiquidQueries

Perform queries on your ActiveRecord collections directly from Liquid templates with the help of Ransack.

Usage

Add a method to a drop that returns a collection:

class MyDrop < Liquid::Drop
  def users
    LiquidQueries::Collection.new(collection: User.all)
  end
end

Then do something like this in your Liquid template:

Kasper's ID is: {{ my_drop.users.ransack.first_name_eq.Kasper.first.id }}
Kasper's last name is {{ my_drop.users.ransack.first_name_eq.Kasper.first.last_name }}

Or something like this:

Users with a name that contains "kasper":

{% for user in my_drop.users.ransack.name_cont.kasper.to_a %}
  {{ user.id }} - {{ user.first_name }} {{ user.last_name }}
{% endfor %}

Installation

Add this line to your application's Gemfile:

gem 'liquid_queries'

And then execute:

$ bundle

Or install it yourself as:

$ gem install liquid_queries

Contributing

Contribution directions go here.

License

The gem is available as open source under the terms of the MIT License.