{"id":16070667,"url":"https://github.com/gbh/liquid_tag_with_params","last_synced_at":"2025-04-05T10:15:08.190Z","repository":{"id":56881384,"uuid":"103590147","full_name":"GBH/liquid_tag_with_params","owner":"GBH","description":"Liquid Markup Tag that accepts parameters","archived":false,"fork":false,"pushed_at":"2017-09-23T16:42:20.000Z","size":18,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-11T02:46:23.236Z","etag":null,"topics":["liquid","liquid-templating-engine","ruby"],"latest_commit_sha":null,"homepage":null,"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/GBH.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-14T23:02:13.000Z","updated_at":"2017-09-20T16:51:54.000Z","dependencies_parsed_at":"2022-08-20T22:31:20.303Z","dependency_job_id":null,"html_url":"https://github.com/GBH/liquid_tag_with_params","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GBH%2Fliquid_tag_with_params","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GBH%2Fliquid_tag_with_params/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GBH%2Fliquid_tag_with_params/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GBH%2Fliquid_tag_with_params/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GBH","download_url":"https://codeload.github.com/GBH/liquid_tag_with_params/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247318746,"owners_count":20919483,"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","liquid-templating-engine","ruby"],"created_at":"2024-10-09T07:06:18.351Z","updated_at":"2025-04-05T10:15:08.161Z","avatar_url":"https://github.com/GBH.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Liquid Tag With Params\n[![Gem Version](https://img.shields.io/gem/v/liquid_tag_with_params.svg?style=flat)](http://rubygems.org/gems/liquid_tag_with_params) [![Gem Downloads](https://img.shields.io/gem/dt/liquid_tag_with_params.svg?style=flat)](http://rubygems.org/gems/liquid_tag_with_params) [![Build Status](https://img.shields.io/travis/GBH/liquid_tag_with_params.svg?style=flat)](https://travis-ci.org/GBH/liquid_tag_with_params)\n\nThis is a `Liquid::TagWithParams` that extends `Liquid::Tag` by adding support for, you guessed it, params.\n\n## Install\n\nAdd gem to your Gemfile:\n\n```ruby\ngem 'liquid_tag_with_params', '~\u003e 0.0.1'\n```\n\n## Usage\n\nThis gem is primarily for extending Liquid [by creating your own tags](https://github.com/Shopify/liquid/wiki/Liquid-for-Programmers#create-your-own-tags). Out of the box `Liquid::Tag`\naccepts a string and that's about it. `Liquid::TagWithParams` will take that\nstring and will make parameters out of it so you can use them during rendering.\n\nHere's an example of such tag:\n\n```ruby\nrequire 'liquid/tag_with_params'\n\nclass ShuffleTag \u003c Liquid::TagWithParams\n  def initialize(tag_name, params, tokens)\n     super\n  end\n\n  def render(context)\n    # assuming that last params were of key: value format\n    options = @params.extract_options!\n\n    # note: keys and values are always strings\n    times = options[\"times\"] || 1\n\n    # shuffle really hard\n    times.to_i.times do\n      @params.shuffle!\n    end\n\n    @params.join(', ')\n  end\nend\n\nLiquid::Template.register_tag('shuffle', ShuffleTag)\n```\n\n```ruby\n@template = Liquid::Template.parse(\"{% shuffle 1, 2, 3, 4, times: 5 %}\")\n@template.render    # =\u003e \"2, 1, 3, 4\"\n```\n\n---\nCopyright 2017, Oleg Khabarov\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgbh%2Fliquid_tag_with_params","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgbh%2Fliquid_tag_with_params","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgbh%2Fliquid_tag_with_params/lists"}