3 ms·
I'll give it a try in a personal project but I hardly see myself asking my designers to use this template system.. Call me grumpy or old, but when working in a
by d0m 14y ago
I'll give it a try in a personal project but I hardly see myself asking my designers to use this template system.. Call me grumpy or old, but when working in a team, I like to keep template files as close to html as possible. It's so much easier to use a technology that everyone understands or to hire externally to speed things up.
- lukev 14y agoThat's sort of the point, though: the templates are completely HTML. There's nothing else in them at all. Your designers can write straight up HTML and not worry about templating at all. Of course, then it's on you as a developer to use Enlive to replace whatever stub/sample elements are present in the HTML with real data, so it's not an entirely free lunch.
- simonw 14y agoThat doesn't fit my experience of how designers work with templates. The problem with this style of template system is that it's very tightly coupled to the HTML of the template. If a designer wants to e.g. change the class on an element (because they want to use a CSS class from bootstrap) they can't without worrying about what's in the clojure code. It becomes almost impossible for them to make anything more than a trivial change without a full understanding of the code that will be manipulating their templates.
- pmjordan 14y agoHmm, I've only used enlive on a small project, and that was quite a while back (I haven't done any webdev lately) and I generally ended up marking my templated elements with special ids or classes. Artificial example coming up: <ul> <li class="item-template"> <a href="#" class="item-link-template"><strong class="item-caption-template">Some dummy caption</strong></a> — <span class="item-description-standin">Some dummy description</span> </li> </ul> The item-template marks the outer-most element to use for repetition. The item-link-template can be used to set the href attribute. The contents of the tag marked with item-caption-template will be replaced with whatever content. The item-description-standin gets replaced with content outright. If you, say, want to remove the <strong> tags around the caption, just move the templating class to the parent item. <ul> <li class="item-template"> <a href="#" class="item-link-template item-caption-template">Some dummy caption</a> — <span class="item-description-standin">Some dummy description</span> </li> </ul> If you come up with some conventions, e.g. "-standin" gets replaced completely, whereas "-template" just gets transformed; each marker is only used for one purpose (don't conflate the link and the caption marker in the latter example), it works rather well, probably better than any other templating system I've used. My only gripes with Enlive at the time were that it was overly macro-heavy (def'ing everything as opposed to returning values), and loading templates was quite slow, which made on-the-fly modifications to HTML generated elsewhere ineffecient. I suspect both are better these days, as it was still heavily in development at the time.
- deleted 14y ago[deleted]