On second thought, this is actually not that critical for what I'm trying to
accomplish, and I'm not sure yet if I'll ever use such a feature. Macros
that define snippets will probably suffice.
(deftemplate my-app6 "app2.html"
  [widgets]
  [[:div (attr? :tiptree:replace)]]
    (fn [node]
      (let [widgetType (:tiptree:replace (:attrs node))]
((snippet "widget.html" [[:div (attr= :tiptree:widget (str widgetType))]]
 [widget]
 [:div.value] (content (if widget
 (:value widget)
 "foo")))
 ((keyword widgetType) widgets)))))

(apply str
       (my-app6 {:widgetA {:value "0"},
 :widgetB {:value "1"}}))

Works for me, and this was in general the use case I was thinking of.


On Thu, Apr 16, 2009 at 4:24 PM, David Nolen <dnolen.li...@gmail.com> wrote:

> Because predicates in selectors no longer need to be quoted it seems you
> can't use Enlive selectors in a first class way with snippets:
> (let [aselector [[:div (attr= :tiptree:widget "widgetA")]]]
>   ((snippet "widget.html" aselector
>     [some-map]
>     [:div.value] (content "foo")) {}))
>
> I believe this might be one of my final big requests :) I personally don't
> mind the quoted predicate forms, especially if this would simplify making
> selectors first class.  This would allow templates to dynamically generate
> snippets based on the properties of a particular node.
>
> There's been a wild flurry of updates to Enlive recently and I am extremely
> excited about the possibilities.  Enlive is an idea which should be ripped
> off by every web framework worth talking about! ;) Thanks again for creating
> and maintaining it.
>
> On Thu, Apr 16, 2009 at 7:15 AM, Christophe Grand 
> <christo...@cgrand.net>wrote:
>
>>
>> Tom,
>>
>> The redesign is nearly over (at least from a user standpoint), you may
>> want to check it http://github.com/cgrand/enlive/tree/right
>>
>> Christophe
>>
>> Tom Hickey a écrit :
>> > Hi Christophe,
>> >
>> > I keep running into the same problem with elements getting replaced.
>> > I'm trying to set the content of an element with raw html (from a
>> > snippet) and  unable to avoid both 1) the html getting escaped and 2)
>> > the element getting replaced. I can avoid one or the other, via
>> > escaped or text, just not both.
>> >
>> > I'm looking forward to see what you've got planned for the redesign,
>> > as I'd really like to see this "feature" go away.
>> >
>> > Cheers,
>> > Tom
>> >
>> > On Mar 20, 3:59 am, Christophe Grand <christo...@cgrand.net> wrote:
>> >
>> >> Phil Hagelberg a écrit :
>> >>
>> >>
>> >>> But I did notice you have the use test-is line commented out in the
>> >>> implementation; it seems a bit unfortunate to have to uncomment that
>> to
>> >>> run the tests and hope you remember to re-comment it before you
>> commit.
>> >>>
>> >> The last commit was during the transition to lazy-seq and test-is was
>> >> broken.
>> >> I'll fix that.
>> >>
>> >> --
>> >> Professional:http://cgrand.net/(fr)
>> >> On Clojure:http://clj-me.blogspot.com/(en)
>> >>
>> > >
>> >
>> >
>>
>>
>> --
>> Professional: http://cgrand.net/ (fr)
>> On Clojure: http://clj-me.blogspot.com/ (en)
>>
>>
>>
>> >>
>>
>

--~--~---------~--~----~------------~-------~--~----~
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
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