Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aguxez/pastry
Turn maps and keyword lists into query strings.
https://github.com/aguxez/pastry
elixir pastry query-string-builder url
Last synced: 2 months ago
JSON representation
Turn maps and keyword lists into query strings.
- Host: GitHub
- URL: https://github.com/aguxez/pastry
- Owner: aguxez
- Created: 2018-01-15T23:14:03.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-04-13T20:34:49.000Z (over 6 years ago)
- Last Synced: 2024-09-24T08:35:02.516Z (3 months ago)
- Topics: elixir, pastry, query-string-builder, url
- Language: Elixir
- Homepage:
- Size: 19.5 KB
- Stars: 9
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Pastry - Turn maps and keyword lists into query Strings.
## Pastry is a [Quiche](http://github.com/chrismissal/quiche) fork in Elixir. [![Build Status](https://travis-ci.org/aguxez/pastry.svg?branch=master)](https://travis-ci.org/aguxez/pastry)
### Install
```elixir
{:pastry, "~> 0.3.0"}
```### Usage
```elixir
iex> Pastry.to_query_string(%{param: ~w(this is a parameters list), words: "Elixir is fun!"})
"?param=this¶m=is¶m=a¶m=parameters¶m=list&words=Elixir%20is%20fun!"Pastry.to_query_string([param: ~w(this is a parameters list), words: "Elixir is fun!"])
"?param=this¶m=is¶m=a¶m=parameters¶m=list&words=Elixir%20is%20fun!"
```### You can pass options as to which type of case to use
```elixir
# use "camel" or "pascal"
iex> Pastry.to_query_string([some_words: ~w(some list), text_word: "Pascal"], case: "pascal")
"?SomeWords=some&SomeWords=list&TextWord=Pascal"
...
iex> Pastry.to_query_string(%{some_words: "A word"}, case: "camel")
"?someWords=A%20word"
```### And if passing case options is not enough
You can just pass an arity 1 function with the `:func` option```elixir
iex> Pastry.to_query_string([text_message: "some word"], func: &String.upcase/1)
"?TEXT_MESSAGE=some%20word"
```