Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bunopnu/e2h
HTML generator for Erlang
https://github.com/bunopnu/e2h
erlang html html-generator html5 rebar3
Last synced: 3 months ago
JSON representation
HTML generator for Erlang
- Host: GitHub
- URL: https://github.com/bunopnu/e2h
- Owner: bunopnu
- License: mit
- Created: 2023-09-25T20:58:24.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-04-23T10:15:42.000Z (9 months ago)
- Last Synced: 2024-10-03T12:20:27.561Z (4 months ago)
- Topics: erlang, html, html-generator, html5, rebar3
- Language: Erlang
- Homepage: https://hex.pm/packages/e2h
- Size: 48.8 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# e2h
`e2h` (Erlang to HTML) is an Erlang module designed to generate HTML content within the Erlang.
It provides functions for encoding HTML elements and attributes, as well as escaping dangerous characters within HTML content.This module is suitable for developers who need to programmatically generate HTML documents or elements in their Erlang applications.
[![Test Status](https://github.com/bunopnu/e2h/actions/workflows/test.yml/badge.svg)](https://github.com/bunopnu/e2h/actions/workflows/test.yml)
[![Coverage Status](https://coveralls.io/repos/github/bunopnu/e2h/badge.svg?branch=main)](https://coveralls.io/github/bunopnu/e2h)
[![Hex Version](https://img.shields.io/hexpm/v/e2h.svg)](https://hex.pm/packages/e2h)## Installation
Package can be installed by adding `e2h` to your list of dependencies:
```erlang
{deps, [{e2h, "0.4.2"}]}.
```## Usage Example
Here's a simple example of how to use `e2h` to generate an HTML document in Erlang:
```erlang
UserStatus = <<"busy">>,
UserProfileImage = <<"https://example.com/image.jpeg">>,
UserName = <<"bob">>,
UserJob = <<"data scientist">>,Document = [
{<<"div">>, [{<<"class">>, <<"user">>}, {<<"status">>, UserStatus}], [
{<<"img">>, [{<<"href">>, UserProfileImage}]},
{<<"div">>, [], [
{<<"h1">>, [], [UserName]},
{<<"p">>, [], [UserJob]}
]}
]}
],e2h:render_fragment(Document).
% (output is manually formatted for readme)
%
%
%
%
%bob
%data scientist
%
%
```## Documentation
For documentation, please refer to the official [HexDocs](https://hexdocs.pm/e2h) page.
## License
`e2h` is licensed under the MIT license.