Hi!

Initially I created a mess of interlinked functions for rendering HTML via hiccup.

I have few pages with parts that may vary or may be present or not based on whether the user is logged in as admin.

With the desire to test for the role in a single place and for composing the views in a uniform way, I created a little framework and now wonder if I'm thinking too complicated, or if this seems sound. Can you suggest improvements or alternatives?


The outcome is that I can define my views via defviews:
https://github.com/thorwil/tlog-clj-gae/blob/4440f729001ef14ea63115c69f0c868bc59e4686/src/tlog/views/views.clj

The roles are cumulative.

Every view defined in this way expects a role and a map (from the datastore). The maps is handed through all elements in the vector (except if it happens to be a def). The html is assembled as value to :buildup. Every element may read and update/add arbitrary key-vals.

All the slightly complicated business happens here:

https://github.com/thorwil/tlog-clj-gae/blob/4440f729001ef14ea63115c69f0c868bc59e4686/src/tlog/views/compose.clj

To allow the rather straightforward parts:

https://github.com/thorwil/tlog-clj-gae/blob/4440f729001ef14ea63115c69f0c868bc59e4686/src/tlog/views/parts.clj

The {:keys} specified are like slots. If one is nil, Hiccup makes it fall out.


--
Thorsten Wilms

thorwil's design for free software:
http://thorwil.wordpress.com/

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to