frozen-filters-js
Liquid Tags for liquidjs
Description
Filters for liquidjs template engine.
These filters are also available as a ruby gem.
Installation
npm i frozen-filter-js
Usage
var liquid = require("liquidjs");
var frozenFilters = require("frozen-filters-js").filters;
var engine = liquid();
frozenFilters.registerFilters(engine);
var vars = {
url: 'http://www.example.com/first/second/index.html?param1=value1¶m2=value2'
};
engine
.parseAndRender('', vars)
.then(function(result) {
// expects http://www.example.com/first/second/index?param1=value1¶m2=value2
console.log(result);
});
Filters
Url Filters
-
remove_ext
- Removes the extension part of an url.
e.g.http://www.example.com/first/second/index?param1=value1¶m2=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¶m2=value2
.
Array Filters
-
array_head
- Returns the firstN
elements of an array.
e.g.page{"layout"=>"page", "title"=>"frozen-filters-js", "permalink"=>"/products/frozen-filters-js/", "content"=>"Liquid Tags for liquidjs\n\n## Description\n[](https://badge.fury.io/js/frozen-filters-js)\n[](https://travis-ci.org/a-bentofreire/frozen-filters-js) \n \nFilters for [liquidjs](https://github.com/harttle/liquidjs) template engine. \nThese filters are also available as a [ruby gem](https://rubygems.org/gems/frozen-filters).\n\n## Installation\n
npm i frozen-filter-js\n\n## Usage\n{% highlight js %}\nvar liquid = require(\"liquidjs\");\nvar frozenFilters = require(\"frozen-filters-js\").filters;\n\nvar engine = liquid();\nfrozenFilters.registerFilters(engine);\n\nvar vars = {\n url: 'http://www.example.com/first/second/index.html?param1=value1¶m2=value2'\n};\n\nengine\n .parseAndRender('{{ url | remove_ext }}', vars)\n .then(function(result) {\n // expects http://www.example.com/first/second/index?param1=value1¶m2=value2\n console.log(result);\n });\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¶m2=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¶m2=value2.\n \n### Array Filters\n \n-
array_head- Returns the first
Nelements 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
Nelements 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 \nThe 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¶m2=value2. \n- punycodes: \ne.g.
https://xn–jp-cd2fp15c.xn–fsq.jp/abc/index.html?param1=value1¶m2=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-js/", "name"=>"frozen-filters-js.md", "path"=>"product-pages/frozen-filters-js.md", "url"=>"/products/frozen-filters-js/"}
=~["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 lastN
elements of an array.
e.g.page{"layout"=>"page", "title"=>"frozen-filters-js", "permalink"=>"/products/frozen-filters-js/", "content"=>"Liquid Tags for liquidjs\n\n## Description\n[](https://badge.fury.io/js/frozen-filters-js)\n[](https://travis-ci.org/a-bentofreire/frozen-filters-js) \n \nFilters for [liquidjs](https://github.com/harttle/liquidjs) template engine. \nThese filters are also available as a [ruby gem](https://rubygems.org/gems/frozen-filters).\n\n## Installation\n
npm i frozen-filter-js\n\n## Usage\n{% highlight js %}\nvar liquid = require(\"liquidjs\");\nvar frozenFilters = require(\"frozen-filters-js\").filters;\n\nvar engine = liquid();\nfrozenFilters.registerFilters(engine);\n\nvar vars = {\n url: 'http://www.example.com/first/second/index.html?param1=value1¶m2=value2'\n};\n\nengine\n .parseAndRender('{{ url | remove_ext }}', vars)\n .then(function(result) {\n // expects http://www.example.com/first/second/index?param1=value1¶m2=value2\n console.log(result);\n });\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¶m2=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¶m2=value2.\n \n### Array Filters\n \n-
array_head- Returns the first
Nelements 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
Nelements 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 \nThe 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¶m2=value2. \n- punycodes: \ne.g.
https://xn–jp-cd2fp15c.xn–fsq.jp/abc/index.html?param1=value1¶m2=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-js/", "name"=>"frozen-filters-js.md", "path"=>"product-pages/frozen-filters-js.md", "url"=>"/products/frozen-filters-js/"}
=~["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-js", "permalink"=>"/products/frozen-filters-js/", "content"=>"Liquid Tags for liquidjs\n\n## Description\n[](https://badge.fury.io/js/frozen-filters-js)\n[](https://travis-ci.org/a-bentofreire/frozen-filters-js) \n \nFilters for [liquidjs](https://github.com/harttle/liquidjs) template engine. \nThese filters are also available as a [ruby gem](https://rubygems.org/gems/frozen-filters).\n\n## Installation\n
npm i frozen-filter-js\n\n## Usage\n{% highlight js %}\nvar liquid = require(\"liquidjs\");\nvar frozenFilters = require(\"frozen-filters-js\").filters;\n\nvar engine = liquid();\nfrozenFilters.registerFilters(engine);\n\nvar vars = {\n url: 'http://www.example.com/first/second/index.html?param1=value1¶m2=value2'\n};\n\nengine\n .parseAndRender('{{ url | remove_ext }}', vars)\n .then(function(result) {\n // expects http://www.example.com/first/second/index?param1=value1¶m2=value2\n console.log(result);\n });\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¶m2=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¶m2=value2.\n \n### Array Filters\n \n-
array_head- Returns the first
Nelements 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
Nelements 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 \nThe 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¶m2=value2. \n- punycodes: \ne.g.
https://xn–jp-cd2fp15c.xn–fsq.jp/abc/index.html?param1=value1¶m2=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-js/", "name"=>"frozen-filters-js.md", "path"=>"product-pages/frozen-filters-js.md", "url"=>"/products/frozen-filters-js/"}
returns:
<li>first</li>
<li>second</li>
The 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¶m2=value2
. - punycodes:
e.g.https://xn--jp-cd2fp15c.xn--fsq.jp/abc/index.html?param1=value1¶m2=value2
.
Copyrights
© 2018 Alexandre Bento Freire