Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
24 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,38 @@ | ||
# demo | ||
# Demo 2 | ||
|
||
project.clj | ||
----------- | ||
|
||
For the second demo we included two libraries: hiccup and | ||
compojure. | ||
In our second demo we added two libraries to help us with Clojure | ||
development web development | ||
|
||
https://github.com/weavejester/hiccup | ||
https://github.com/weavejester/compojure | ||
* [Hiccup](https://github.com/weavejester/hiccup) | ||
* [Compojure](https://github.com/weavejester/compojure) | ||
|
||
For easier request handling we also added ring-core and | ||
ring-devel. Both include definition of ring "middleware". | ||
See [project.clj](project.clj) for changes. | ||
|
||
Hiccup | ||
------ | ||
|
||
Hiccup is a library for HTML rendering from Clojure data | ||
structures | ||
Hiccup library uses Clojure data types to express HTML structure. | ||
HTML tree is expressed using vectors and list. Vectors start | ||
with element keyword and are optionally followed with map | ||
of attributes. | ||
|
||
See [page.clj](src/demo/page.clj) for hello-world example. | ||
|
||
Compojure | ||
--------- | ||
|
||
Is a DSL (Domain Specific Language) for writing routing | ||
information for Ring. | ||
Compojure defines DSL (domain specific language) for request routing. | ||
In [core.clj](src/demo/core.clj) we use it fullfil request GET /. | ||
More complex examples will follow in Demo 3. | ||
|
||
Middleware | ||
---------- | ||
|
||
Function `jetty-handler` in [core.clj](src/demo/core.clj) shows how | ||
you can extend basic jetty functionallity using middleware. `jetty-handler` | ||
is now composed from four independent parts - our routing function (`main-route`), | ||
then two functions for processing arguments and development utility which | ||
wraps any exception and produces readable output both in browser and in RPEL. |