{"id":13879564,"url":"https://github.com/chamnap/liquid-rails","last_synced_at":"2025-07-16T15:32:29.553Z","repository":{"id":19731150,"uuid":"22987330","full_name":"chamnap/liquid-rails","owner":"chamnap","description":"Renders liquid templates with layout and partial support","archived":false,"fork":false,"pushed_at":"2023-10-09T03:24:42.000Z","size":142,"stargazers_count":115,"open_issues_count":19,"forks_count":101,"subscribers_count":23,"default_branch":"master","last_synced_at":"2024-08-07T08:12:49.916Z","etag":null,"topics":["liquid","rails","ruby"],"latest_commit_sha":null,"homepage":"https://rubygems.org/gems/liquid-rails","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chamnap.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-08-15T11:13:49.000Z","updated_at":"2024-06-10T14:55:39.000Z","dependencies_parsed_at":"2023-01-11T20:34:51.213Z","dependency_job_id":null,"html_url":"https://github.com/chamnap/liquid-rails","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chamnap%2Fliquid-rails","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chamnap%2Fliquid-rails/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chamnap%2Fliquid-rails/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chamnap%2Fliquid-rails/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chamnap","download_url":"https://codeload.github.com/chamnap/liquid-rails/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226143895,"owners_count":17580245,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["liquid","rails","ruby"],"created_at":"2024-08-06T08:02:25.372Z","updated_at":"2024-11-24T08:31:28.353Z","avatar_url":"https://github.com/chamnap.png","language":"Ruby","readme":"[![Build Status](https://travis-ci.org/chamnap/liquid-rails.svg?branch=master)](https://travis-ci.org/yoolk/liquid-rails)[![Coverage Status](https://coveralls.io/repos/yoolk/liquid-rails/badge.png?branch=master)](https://coveralls.io/r/yoolk/liquid-rails?branch=master)[![Gem Version](https://badge.fury.io/rb/liquid-rails.svg)](http://badge.fury.io/rb/liquid-rails)\n# Liquid-Rails\n\nIt allows you to render `.liquid` templates with layout and partial support. It also provides filters, tags, drops class to be used inside your liquid template.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n    gem 'liquid-rails'\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install liquid-rails\n\n## Usage\n\nIn order to render with layout, in your layout file `app/views/layouts/application.liquid`, put this:\n\n```html\n{{ content_for_layout }}\n```\n\n```html\n# It will render app/views/home/_partial.liquid when the current controller is `HomeController`.\n{% include 'partial' %}\n\n# It will render app/views/shared/_partial.liquid.\n{% include 'shared/partial' %}\n```\n\n### Template Rendering\n\nBy default, **Liquid-Rails** makes all instance variables from controller available to liquid template. To limit only some instance variables, do this inside your controller:\n\n```ruby\ndef liquid_assigns\n  { 'listing' =\u003e current_listing, 'content_for_header' =\u003e content_for_header, 'current_account' =\u003e current_account }\nend\n```\n\nBy default, **Liquid-Rails** makes all your helper methods inside your rails app available to liquid template. To limit only some helpers, do this inside your controller:\n\n```ruby\ndef liquid_filters\n  []\nend\n```\n\nYou can render liquid templates from other template engines, eg. `erb`, `haml`, ...\n\n```ruby\n= render 'shared/partial.liquid'\n```\n\n### Filter\n\n\u003e Filters are simple methods that modify the output of numbers, strings, variables and objects. They are placed within an output tag `{{` `}}` and are separated with a pipe character `|`.\n\nCurrently, **Liquid-Rails** adds only the followings:\n\n1. [AssetTagFilter](https://github.com/yoolk/liquid-rails/blob/master/lib/liquid-rails/filters/asset_tag_filter.rb)\n2. [AssetUrlFilter](https://github.com/yoolk/liquid-rails/blob/master/lib/liquid-rails/filters/asset_url_filter.rb)\n3. [DateFilter](https://github.com/yoolk/liquid-rails/blob/master/lib/liquid-rails/filters/date_filter.rb)\n4. [NumberFilter](https://github.com/yoolk/liquid-rails/blob/master/lib/liquid-rails/filters/number_filter.rb)\n5. [SanitizeFilter](https://github.com/yoolk/liquid-rails/blob/master/lib/liquid-rails/filters/sanitize_filter.rb)\n6. [TextFilter](https://github.com/yoolk/liquid-rails/blob/master/lib/liquid-rails/filters/text_filter.rb)\n7. [TranslateFilter](https://github.com/yoolk/liquid-rails/blob/master/lib/liquid-rails/filters/translate_filter.rb)\n8. [UrlFilter](https://github.com/yoolk/liquid-rails/blob/master/lib/liquid-rails/filters/url_filter.rb)\n9. [MiscFilter](https://github.com/yoolk/liquid-rails/blob/master/lib/liquid-rails/filters/misc_filter.rb)\n\n### Tag\n\n\u003e Liquid tags are the programming logic that tells templates what to do. Tags are wrapped in: `{%` `%}`.\n\nCurrently, **Liquid-Rails** adds only the followings:\n\n1. [csrf_meta_tags](https://github.com/yoolk/liquid-rails/blob/master/lib/liquid-rails/tags/csrf_meta_tags.rb)\n2. [google_analytics_tag](https://github.com/yoolk/liquid-rails/blob/master/lib/liquid-rails/tags/google_analytics_tag.rb)\n3. [javascript_tag](https://github.com/yoolk/liquid-rails/blob/master/lib/liquid-rails/tags/javascript_tag.rb)\n4. [paginate](https://github.com/yoolk/liquid-rails/blob/master/lib/liquid-rails/tags/paginate_tag.rb)\n4. [content_for](https://github.com/yoolk/liquid-rails/blob/master/lib/liquid-rails/tags/content_for.rb)\n\n### Drop Class\n\n\u003e Drops let you provide the user with custom functionality. They are very much like a standard Ruby class, but have all unused and potentially dangerous methods removed. From the user's perspective a drop acts very much like a Hash, though methods are accessed with dot-notation as well as element selection. A drop method cannot be invoked with arguments. Drops are called just-in-time, thus allowing you to lazily load objects.\n\nGiven two models, a Post(title: string, body: text) and a Comment(name:string, body:text, post_id:integer), you will have two drops:\n\n```ruby\nclass PostDrop \u003c Liquid::Rails::Drop\n  attributes :id, :title, :body\n\n  has_many :comments\nend\n```\n\nand\n\n```ruby\nclass CommentDrop \u003c Liquid::Rails::Drop\n  attributes :id, :name, :body\n\n  belongs_to :post\nend\n```\n\nCheck out more [examples](https://github.com/yoolk/liquid-rails/blob/master/spec/fixtures/poro.rb).\n\nIt works for any ORMs. The PORO should include `Liquid::Rails::Droppable`. That's all you need to do to have your POROs supported.\n\n### RSpec\n\nIn spec_helper.rb, you'll need to require the matchers:\n\n```ruby\nrequire 'liquid-rails/matchers'\n```\n\nExample:\n\n```ruby\ndescribe PostDrop do\n  it { should have_attribute(:id) }\n  it { should have_attribute(:title) }\n  it { should have_attribute(:body) }\n  it { should have_many(:comments) }\nend\n```\n\n```ruby\ndescribe CommentDrop do\n  it { should have_attribute(:id) }\n  it { should have_attribute(:name) }\n  it { should have_attribute(:body) }\n  it { should belongs_to(:post) }\nend\n```\n\n## Contributors\n\n* [Radin Reth](https://github.com/radin-reth/)\n\n## Authors\n\n* [Chamnap Chhorn](https://github.com/chamnap)\n","funding_links":[],"categories":["Ruby"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchamnap%2Fliquid-rails","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchamnap%2Fliquid-rails","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchamnap%2Fliquid-rails/lists"}