Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/parroty/exprintf
A printf / sprintf library for Elixir. It works as a wrapper for :io.format.
https://github.com/parroty/exprintf
Last synced: 2 months ago
JSON representation
A printf / sprintf library for Elixir. It works as a wrapper for :io.format.
- Host: GitHub
- URL: https://github.com/parroty/exprintf
- Owner: parroty
- License: mit
- Created: 2013-08-24T03:13:36.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2024-08-05T09:09:16.000Z (5 months ago)
- Last Synced: 2024-10-05T15:16:47.886Z (3 months ago)
- Language: Elixir
- Homepage:
- Size: 26.4 KB
- Stars: 34
- Watchers: 2
- Forks: 12
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
- freaking_awesome_elixir - Elixir - A printf / sprintf library for Elixir, works as a wrapper for :io.format. (Miscellaneous)
- fucking-awesome-elixir - exprint - A printf / sprintf library for Elixir, works as a wrapper for :io.format. (Miscellaneous)
- awesome-elixir - exprint - A printf / sprintf library for Elixir, works as a wrapper for :io.format. (Miscellaneous)
README
ExPrintf [![Build Status](https://secure.travis-ci.org/parroty/exprintf.png?branch=master "Build Status")](http://travis-ci.org/parroty/exprintf)
============
A printf / sprintf library for Elixir. It works as a wrapper for :io.format.When learning Elixir / Erlang, remembering :io.format style is a little tough. This one can be used as syntax sugar, or an util to convert printf format to Elixir (Erlang) one.
# Examples
## Basic Usage
```elixir
defmodule Sample do
import ExPrintfdef test do
printf("number = %d\n", [10])
# -> number = 10
IO.puts sprintf("string = %s", ["abc"])
# -> string = abcformat = parse_printf("format = %d %.2f\n")
IO.inspect format
# -> "format = ~w ~.2f\n"
:io.format(format, [10, 10.153])
# -> format = 10 10.15IO.puts :io_lib.format(format, [10, 10.153])
# -> format = 10 10.15
end
endSample.test
```## Sample Execution
```
$ mix run sample.ex
number = 10
string = abc
"format = ~w ~.2f\n"
format = 10 10.15
```## iex
```
$ git clone [email protected]:parroty/exprintf.git
$ cd exprintf
$ ./run_iex.sh
$ iex(1) -> parse_printf("%d")
"~w"
```## Dynamo
The following hosts a sample dynamo application for the printf format conversion.http://dynamo-exprintf.herokuapp.com/
## TODO
- Improve error checking
- Improve format support coverage
- sprintf("%05d", [-10]) results in "00-10", instead of "-00010".