Feature #6 Auto-reloading of templates

43 views
Skip to first unread message

Robert Campbell

unread,
Nov 26, 2009, 2:16:40 AM11/26/09
to enliv...@googlegroups.com
Has there been any progress on this feature? If not, I'd be willing to
try implementing it. Any background/tips welcome.

Christophe Grand

unread,
Nov 30, 2009, 10:39:56 AM11/30/09
to enliv...@googlegroups.com
Hi,


On Thu, Nov 26, 2009 at 8:16 AM, Robert Campbell <rrc...@gmail.com> wrote:
Has there been any progress on this feature? If not, I'd be willing to
try implementing it. Any background/tips welcome.

No progress on this feature -- to be frank I'm still on the fence about autoreload being a good idea.
Either you poll resources to see if they changed, or you perform this check on each call to the template (templates being functions, you can wrap it in another function which reeval it as needed.)
If you choose to poll, an easy solution is to reload the whole namespace.

I think auto reload doesn't need to depend on Enlive.
A var could have a metadata :reload? holding a function with no args, and at the repl you would type something like:
user=> (autoreload your.namespace)
and autoreload would search all vars of the namespace for those metadata and either wrap them or set up the polling thread.

What do you think?

Christophe

Robert Campbell

unread,
Dec 26, 2009, 2:24:46 PM12/26/09
to enliv...@googlegroups.com
Hi Christophe,

I ended up wrapping the snippets/templates in a function like this:

(defn view-wrapper [foo]
(defsnippet view "snippet.html" [:html] [foo]
[:title] (content (foo :bar))
(view foo))

(view-wrapper foo)

This works perfectly for me. I'm not too concerned with performance at
this stage, so we'll see. I'm interested in your namespace reloading
idea and might try it out once my project is farther along.

Rob

> --
>
> You received this message because you are subscribed to the Google Groups
> "Enlive" group.
> To post to this group, send email to enliv...@googlegroups.com.
> To unsubscribe from this group, send email to
> enlive-clj+...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/enlive-clj?hl=en.
>

Reply all
Reply to author
Forward
0 new messages