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
- Host: GitHub
- URL: https://github.com/hellerve/exemplar
- Owner: hellerve
- License: gpl-2.0
- Created: 2016-03-01T14:19:21.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2016-09-01T14:41:13.000Z (over 9 years ago)
- Last Synced: 2025-06-03T22:56:51.066Z (10 months ago)
- Size: 9.77 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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!