An open API service indexing awesome lists of open source software.

https://github.com/hellerve/exemplar

An exemplar port for zepto
https://github.com/hellerve/exemplar

Last synced: about 2 months ago
JSON representation

An exemplar port for zepto

Awesome Lists containing this project

README

          

# exemplar

This is a port of the [exemplar](https://github.com/lfex/exemplar) library
to zepto. It is more or less direct, but overcomes one or two of its'
awkwardnesses (and introduces another, yay).

# Usage

The port is compatible enough with the original version to look familiar.

````clojure
(load "exemplar/exemplar")

(++ (doctype) (html (-head) (body (p "i am some text"))))
; => \n

i am some text


(link #{"href" "https://google.com"})
; =>
```

To people who know exemplar, there should be a few things that are new:
1. Multiple child elements need not be wrapped in a list.
2. The attributes on the other hand are presented in the form of a hash map.
3. Elements that provoke nameclashes (namely: `head` and `map`) are prefixed with a hyphen.

This makes the code a bit easier to look at overall (or so I believe).

As in exemplar, one can also define one's own elements:

```clojure
(defelem fancy-custom-element)
(fancy-custom-element (p "i am inside a fancy elem"))
; =>

i am inside a fancy elem


```

To avoid nameclashes, one can also do a `render-as`-style call to `defelem`:

```clojure
(defelem fancy-custom-element "fce")
(fancy-custom-element (p "i am inside a fancy elem"))
; =>

i am inside a fancy elem


```

This is the reason why `-map` renders to ``.


Have fun!