Liquid Tags for jekyllrb

Description

Gem Version Build Status

Liquid filters for shopify liquid template engine.
This ruby gem is a port of frozen-filters-js.

Installation

gem install frozen-filters

Usage

Usage outside jekyllrb:

require 'liquid'
require 'frozen-filters'

vars = {
  'url' => 'http://www.example.com/first/second/index.html?param1=value1&param2=value2'
}

@template = Liquid::Template.parse('')
@template.render(vars)  # http://www.example.com/first/second/index?param1=value1&param2=value2

Usage within jekyllrb:

  • Add to blog Gemfile:
gem "frozen-filters", "~> 0.3.0"
  • Add to plugins section of blog _config.yml:
  - frozen-filters
  • Use the filters on any liquid page. e.g.
/assets/main.css

Filters

Url Filters

  • remove_ext - Removes the extension part of an url.
    e.g. http://www.example.com/first/second/index?param1=value1&param2=value2.

  • remove_qs - Removes the query string part of an url. e.g. http://www.example.com/first/second/index.html.
  • extract_basename - Returns the basename of an url. e.g. index.html.
  • extract_dirname - Returns the dirname of an url. e.g. /first/second.
  • extract_path - Returns the path of an url. e.g. /first/second/index.html.
  • extract_protocol - Returns the protocol. e.g. http.
  • extract_qs - Returns the query string. e.g. param1=value1&param2=value2.

Array Filters

  • array_head - Returns the first N elements of an array.
    e.g. page{"layout"=>"page", "title"=>"frozen-filters", "permalink"=>"/products/frozen-filters/", "content"=>"Liquid Tags for jekyllrb\n\n## Description\n[![Gem Version](https://badge.fury.io/rb/frozen-filters.svg)](https://badge.fury.io/rb/frozen-filters)\n[![Build Status](https://travis-ci.org/a-bentofreire/frozen-filters.svg?branch=master)](https://travis-ci.org/a-bentofreire/frozen-filters) \n \nLiquid filters for shopify [liquid](https://github.com/shopify/liquid) template engine. \nThis ruby gem is a port of [frozen-filters-js](https://github.com/a-bentofreire/frozen-filters-js).\n\n## Installation\ngem install frozen-filters \n\n## Usage\n \nUsage outside jekyllrb: \n \n{% highlight ruby %}\nrequire 'liquid'\nrequire 'frozen-filters'\n\nvars = {\n 'url' => 'http://www.example.com/first/second/index.html?param1=value1&param2=value2'\n}\n\n@template = Liquid::Template.parse('{{ url | remove_ext }}')\n@template.render(vars) # http://www.example.com/first/second/index?param1=value1&param2=value2\n{% endhighlight %}\n \nUsage within jekyllrb: \n \n- Add to blog Gemfile: \n{% highlight ruby %}\ngem \"frozen-filters\", \"~> 0.3.0\"\n{% endhighlight %}\n- Add to plugins section of blog _config.yml: \n{% highlight ruby %}\n - frozen-filters\n{% endhighlight %}\n- Use the filters on any liquid page.\ne.g.\n{% highlight html %}\n{{ \"/assets/main.css\" | remove_ext }}\n{% endhighlight %}\n\n## Filters\n### Url Filters\n \n- remove_ext - Removes the extension part of an url. \ne.g. http://www.example.com/first/second/index?param1=value1&param2=value2.\n \n- remove_qs - Removes the query string part of an url. e.g. http://www.example.com/first/second/index.html.\n- extract_basename - Returns the basename of an url. e.g. index.html.\n- extract_dirname - Returns the dirname of an url. e.g. /first/second.\n- extract_path - Returns the path of an url. e.g. /first/second/index.html.\n- extract_protocol - Returns the protocol. e.g. http.\n- extract_qs - Returns the query string. e.g. param1=value1&param2=value2.\n \n### Array Filters\n \n- array_head - Returns the first N elements of an array. \n e.g. {{ ["first","second","third"] | array_head: 2 }} =~ ["first","second"]. \n If the number of parameters is negative it returns an empty array. \n The the input isn't an array it returns the untouched input. \n \n- array_tail - Returns the last N elements of an array. \n e.g. {{ ["first","second","third"] | array_tail: 2 }} =~ ["first","second"]. \n If the number of parameters is negative it returns an empty array. \n The the input isn't an array it returns the untouched input. \n- array_to_taglist - Transforms an array into an enclosed html tag list separated by newline. \n e.g. {{ ["first","second" | array_to_taglist: "li" }} returns: \n{% highlight html %}\n<li>first</li>\n<li>second</li>\n{% endhighlight %}\n \nIf the input isn't an array, it returns the untouched input.\n \n## Internationalization\n \nThe url filters support domains and paths with:\n- non-latin characters. \ne.g. http://吃.高雄/第一/第二/首頁.html?param1=value1&param2=value2. \n- punycodes: \ne.g. https://xn–jp-cd2fp15c.xn–fsq.jp/abc/index.html?param1=value1&param2=value2. \n \n## Copyrights\n \n© 2018 [Alexandre Bento Freire](https://www.a-bentofreire.com) \n \n \n## License\n \n[MIT License+uuid License](https://github.com/a-bentofreire/uuid-licenses/blob/master/MIT-uuid-license.md) \n", "dir"=>"/products/frozen-filters/", "name"=>"frozen-filters.md", "path"=>"product-pages/frozen-filters.md", "url"=>"/products/frozen-filters/"} =~ ["first","second"].
    If the number of parameters is negative it returns an empty array.
    The the input isn’t an array it returns the untouched input.

  • array_tail - Returns the last N elements of an array.
    e.g. page{"layout"=>"page", "title"=>"frozen-filters", "permalink"=>"/products/frozen-filters/", "content"=>"Liquid Tags for jekyllrb\n\n## Description\n[![Gem Version](https://badge.fury.io/rb/frozen-filters.svg)](https://badge.fury.io/rb/frozen-filters)\n[![Build Status](https://travis-ci.org/a-bentofreire/frozen-filters.svg?branch=master)](https://travis-ci.org/a-bentofreire/frozen-filters) \n \nLiquid filters for shopify [liquid](https://github.com/shopify/liquid) template engine. \nThis ruby gem is a port of [frozen-filters-js](https://github.com/a-bentofreire/frozen-filters-js).\n\n## Installation\ngem install frozen-filters \n\n## Usage\n \nUsage outside jekyllrb: \n \n{% highlight ruby %}\nrequire 'liquid'\nrequire 'frozen-filters'\n\nvars = {\n 'url' => 'http://www.example.com/first/second/index.html?param1=value1&param2=value2'\n}\n\n@template = Liquid::Template.parse('{{ url | remove_ext }}')\n@template.render(vars) # http://www.example.com/first/second/index?param1=value1&param2=value2\n{% endhighlight %}\n \nUsage within jekyllrb: \n \n- Add to blog Gemfile: \n{% highlight ruby %}\ngem \"frozen-filters\", \"~> 0.3.0\"\n{% endhighlight %}\n- Add to plugins section of blog _config.yml: \n{% highlight ruby %}\n - frozen-filters\n{% endhighlight %}\n- Use the filters on any liquid page.\ne.g.\n{% highlight html %}\n{{ \"/assets/main.css\" | remove_ext }}\n{% endhighlight %}\n\n## Filters\n### Url Filters\n \n- remove_ext - Removes the extension part of an url. \ne.g. http://www.example.com/first/second/index?param1=value1&param2=value2.\n \n- remove_qs - Removes the query string part of an url. e.g. http://www.example.com/first/second/index.html.\n- extract_basename - Returns the basename of an url. e.g. index.html.\n- extract_dirname - Returns the dirname of an url. e.g. /first/second.\n- extract_path - Returns the path of an url. e.g. /first/second/index.html.\n- extract_protocol - Returns the protocol. e.g. http.\n- extract_qs - Returns the query string. e.g. param1=value1&param2=value2.\n \n### Array Filters\n \n- array_head - Returns the first N elements of an array. \n e.g. {{ ["first","second","third"] | array_head: 2 }} =~ ["first","second"]. \n If the number of parameters is negative it returns an empty array. \n The the input isn't an array it returns the untouched input. \n \n- array_tail - Returns the last N elements of an array. \n e.g. {{ ["first","second","third"] | array_tail: 2 }} =~ ["first","second"]. \n If the number of parameters is negative it returns an empty array. \n The the input isn't an array it returns the untouched input. \n- array_to_taglist - Transforms an array into an enclosed html tag list separated by newline. \n e.g. {{ ["first","second" | array_to_taglist: "li" }} returns: \n{% highlight html %}\n<li>first</li>\n<li>second</li>\n{% endhighlight %}\n \nIf the input isn't an array, it returns the untouched input.\n \n## Internationalization\n \nThe url filters support domains and paths with:\n- non-latin characters. \ne.g. http://吃.高雄/第一/第二/首頁.html?param1=value1&param2=value2. \n- punycodes: \ne.g. https://xn–jp-cd2fp15c.xn–fsq.jp/abc/index.html?param1=value1&param2=value2. \n \n## Copyrights\n \n© 2018 [Alexandre Bento Freire](https://www.a-bentofreire.com) \n \n \n## License\n \n[MIT License+uuid License](https://github.com/a-bentofreire/uuid-licenses/blob/master/MIT-uuid-license.md) \n", "dir"=>"/products/frozen-filters/", "name"=>"frozen-filters.md", "path"=>"product-pages/frozen-filters.md", "url"=>"/products/frozen-filters/"} =~ ["first","second"].
    If the number of parameters is negative it returns an empty array.
    The the input isn’t an array it returns the untouched input.
  • array_to_taglist - Transforms an array into an enclosed html tag list separated by newline.
    e.g. page{"layout"=>"page", "title"=>"frozen-filters", "permalink"=>"/products/frozen-filters/", "content"=>"Liquid Tags for jekyllrb\n\n## Description\n[![Gem Version](https://badge.fury.io/rb/frozen-filters.svg)](https://badge.fury.io/rb/frozen-filters)\n[![Build Status](https://travis-ci.org/a-bentofreire/frozen-filters.svg?branch=master)](https://travis-ci.org/a-bentofreire/frozen-filters) \n \nLiquid filters for shopify [liquid](https://github.com/shopify/liquid) template engine. \nThis ruby gem is a port of [frozen-filters-js](https://github.com/a-bentofreire/frozen-filters-js).\n\n## Installation\ngem install frozen-filters \n\n## Usage\n \nUsage outside jekyllrb: \n \n{% highlight ruby %}\nrequire 'liquid'\nrequire 'frozen-filters'\n\nvars = {\n 'url' => 'http://www.example.com/first/second/index.html?param1=value1&param2=value2'\n}\n\n@template = Liquid::Template.parse('{{ url | remove_ext }}')\n@template.render(vars) # http://www.example.com/first/second/index?param1=value1&param2=value2\n{% endhighlight %}\n \nUsage within jekyllrb: \n \n- Add to blog Gemfile: \n{% highlight ruby %}\ngem \"frozen-filters\", \"~> 0.3.0\"\n{% endhighlight %}\n- Add to plugins section of blog _config.yml: \n{% highlight ruby %}\n - frozen-filters\n{% endhighlight %}\n- Use the filters on any liquid page.\ne.g.\n{% highlight html %}\n{{ \"/assets/main.css\" | remove_ext }}\n{% endhighlight %}\n\n## Filters\n### Url Filters\n \n- remove_ext - Removes the extension part of an url. \ne.g. http://www.example.com/first/second/index?param1=value1&param2=value2.\n \n- remove_qs - Removes the query string part of an url. e.g. http://www.example.com/first/second/index.html.\n- extract_basename - Returns the basename of an url. e.g. index.html.\n- extract_dirname - Returns the dirname of an url. e.g. /first/second.\n- extract_path - Returns the path of an url. e.g. /first/second/index.html.\n- extract_protocol - Returns the protocol. e.g. http.\n- extract_qs - Returns the query string. e.g. param1=value1&param2=value2.\n \n### Array Filters\n \n- array_head - Returns the first N elements of an array. \n e.g. {{ ["first","second","third"] | array_head: 2 }} =~ ["first","second"]. \n If the number of parameters is negative it returns an empty array. \n The the input isn't an array it returns the untouched input. \n \n- array_tail - Returns the last N elements of an array. \n e.g. {{ ["first","second","third"] | array_tail: 2 }} =~ ["first","second"]. \n If the number of parameters is negative it returns an empty array. \n The the input isn't an array it returns the untouched input. \n- array_to_taglist - Transforms an array into an enclosed html tag list separated by newline. \n e.g. {{ ["first","second" | array_to_taglist: "li" }} returns: \n{% highlight html %}\n<li>first</li>\n<li>second</li>\n{% endhighlight %}\n \nIf the input isn't an array, it returns the untouched input.\n \n## Internationalization\n \nThe url filters support domains and paths with:\n- non-latin characters. \ne.g. http://吃.高雄/第一/第二/首頁.html?param1=value1&param2=value2. \n- punycodes: \ne.g. https://xn–jp-cd2fp15c.xn–fsq.jp/abc/index.html?param1=value1&param2=value2. \n \n## Copyrights\n \n© 2018 [Alexandre Bento Freire](https://www.a-bentofreire.com) \n \n \n## License\n \n[MIT License+uuid License](https://github.com/a-bentofreire/uuid-licenses/blob/master/MIT-uuid-license.md) \n", "dir"=>"/products/frozen-filters/", "name"=>"frozen-filters.md", "path"=>"product-pages/frozen-filters.md", "url"=>"/products/frozen-filters/"} returns:
<li>first</li>
<li>second</li>

If the input isn’t an array, it returns the untouched input.

Internationalization

The url filters support domains and paths with:

  • non-latin characters.
    e.g. http://吃.高雄/第一/第二/首頁.html?param1=value1&param2=value2.
  • punycodes:
    e.g. https://xn--jp-cd2fp15c.xn--fsq.jp/abc/index.html?param1=value1&param2=value2.

Copyrights

© 2018 Alexandre Bento Freire

License

MIT License+uuid License