README.md

# exemplar

[![Build Status][gh-actions-badge]][gh-actions]
[![LFE Versions][lfe badge]][lfe]
[![Erlang Versions][erlang badge]][versions]
[![Tags][github tags badge]][github tags]

*Markup Language Expressions for LFE: creating XML/HTML with S-expressions on the Erlang VM*

[![Project Logo][logo]][logo-large]


#### Contents

* [Introduction](#introduction-)
  * [Supported Tags](#supported-tags-)
  * [Current Status](#current-status-)
  * [About the Name](#about-the-name-)
* [Dependencies](#dependencies-)
* [Installation](#installation-)
* [Documentation](#documentation-)
* [License](#license-)


## Introduction [↟](#contents)

### Supported Tags [↟](#contents)

[![][html5_logo]][html5_logo]

[html5_logo]: priv/images/HTML5_Logo_tiny.png

Right now, only HTML5 is supported. Feel free to submit pull requests to support
older/different tags/elements.

The list of tags was obtained from [Mozilla's HTML 5 documentation][mz]

[mz]: https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/HTML5/HTML5_element_list

Note that XML namespacing hasn't been explored yet, but *should* be possible.


### Current Status [↟](#contents)

As you can see in the example usage below, you can use exemplar to build HTML
strings using LFE S-expressions. However, do note that the project has *just*
started and there are lots of unexplored HTML edge-cases that simply won't work
right now.

If you come across anything, feel free to submit a bug in the github issue
tracker, or even send us a pull request :-)


### About the Name [↟](#contents)

Naming and cache invalidation, right?

The first thought was to name the project ML-expr: ML for HTML, replacing the
"s" of "s-expression". MLEXPR isn't all that pronouncable, so another "e" and
an "a" were added for "exemplar". That's all there is to it.

Also: "Do you know who I *am*?!"[^1]


## Dependencies [↟](#contents)

This project assumes that you have [rebar3](https://github.com/erlang/rebar3)
installed somwhere in your ``$PATH``.


## Installation [↟](#contents)

Just add it to your ``rebar.config`` deps:

```erlang
{deps, [
  ...
  {exemplar, "0.6.0"}
]}.
```

And then do the usual:

```bash
$ rebar3 compile
```

## Usage

For details, see the "Documentation" section below, but here's a quick usage example:

``` lisp
(include-lib "exemplar/include/html-macros.lfe")

(let ((content (html
                 (body
                   (div
                     (p "Here is some content"))))))
  (io:format "~s" (list content)))
```

which prints out the expected:

``` html
<html><body><div><p>Here is some content</p></div></body></html>
```

## Documentation [&#x219F;](#contents)

Documentation for Exemplar is published to the following locations:

* [User Guide](http://lfex.github.io/exemplar/current/user-guide)
* [API Reference](http://lfex.github.io/exemplar/current/api)


## License [&#x219F;](#contents)

Copyright © 2014-2023 Duncan McGreggor

Distributed under the Apache License, Version 2.0.

----

## Footnotes [&#x219F;](#contents)

[^1]: "The first Exemplar was the Juggernaut, who had formerly been Cain Marko, stepbrother to Charles Xavier." See the [Exemplars](https://en.wikipedia.org/wiki/Exemplars_(comics)) wikipedia entry for more details. 

[//]: ---Named-Links---

[logo]: priv/images/juggernaut-tiny.png
[logo-large]: priv/images/juggernaut-large.png
[org]: https://github.com/lfex
[github]: https://github.com/lfex/exemplar
[gitlab]: https://gitlab.com/lfex/exemplar
[versions]: https://github.com/lfex/lanes/blob/master/.github/workflows/cicd.yml
[github tags]: https://github.com/lfex/lanes/tags
[github tags badge]: https://img.shields.io/github/tag/lfex/lanes.svg
[lfe]: https://github.com/lfe/lfe
[lfe badge]: https://img.shields.io/badge/lfe-2.1-blue.svg
[erlang badge]: https://img.shields.io/badge/erlang-21%20to%2026-blue.svg
[github tags]: https://github.com/lfex/exemplar/tags
[github tags badge]: https://img.shields.io/github/tag/lfex/exemplar.svg
[github downloads]: https://img.shields.io/github/downloads/lfex/exemplar/total.svg
[hex badge]: https://img.shields.io/hexpm/v/exemplar.svg?maxAge=2592000
[hex package]: https://hex.pm/packages/exemplar
[hex downloads]: https://img.shields.io/hexpm/dt/exemplar.svg