Re: Enlive questions

2009-07-01 Thread Christophe Grand
On Wed, Jul 1, 2009 at 11:42 PM, cody wrote: > > On Jul 1, 3:45 pm, cody wrote: > > > The use case for this is inserting sub-templates, e.g. site-wide > > common sidebars, footer, etc. Or do you see an alternate way to > > accomplish that goal? > > Eh, looks like I need to read earlier in the t

Re: Enlive questions

2009-07-01 Thread cody
On Jul 1, 3:45 pm, cody wrote: > The use case for this is inserting sub-templates, e.g. site-wide > common sidebars, footer, etc.  Or do you see an alternate way to > accomplish that goal? Eh, looks like I need to read earlier in the thread, apologies for the noise, and thanks again for the f

Re: Enlive questions

2009-07-01 Thread cody
On Jun 27, 3:16 am, Christophe Grand wrote: > Indeed. Fixed. > > user=> (html-resource (java.io.StringReader. "th")) > ({:type :comment, :data " o noes a comment "} {:tag :html, :attrs nil, > :content [{:tag :head, :attrs nil, :content [{:tag :title, :attrs nil, > :content ["t"]}]} {:tag :body,

Re: Enlive questions

2009-06-27 Thread Christophe Grand
Hi Cody! On Sat, Jun 27, 2009 at 8:47 AM, cody wrote: > > Maybe unrelated, but > > =>(html-resource (java.io.StringReader. " >th")) > > ({:type :comment, :data " o noes a comment "}) > > Not the result I would expect. Indeed. Fixed. user=> (html-resource (java.io.StringReader. "th")) ({:type

Re: Enlive questions

2009-06-26 Thread cody
On May 6, 12:36 am, Christophe Grand wrote: > Hello Ryan, > > rzeze...@gmail.com a écrit :> Either I've missed something, orEnlive*appears* > to have problems > > handling comment tags. > > Indeed. I pushed a fix, please tell me whether it works for you now. > > Thanks for the report. > > Chri

Re: Enlive questions

2009-05-07 Thread rzeze...@gmail.com
On May 6, 1:36 am, Christophe Grand wrote: > Hello Ryan, > > rzeze...@gmail.com a écrit :> Either I've missed something, orEnlive*appears* > to have problems > > handling comment tags. > > Indeed. I pushed a fix, please tell me whether it works for you now. > > Thanks for the report. > > Chris

Re: Enlive questions

2009-05-05 Thread David Nolen
Seems to be working great now. On Wed, May 6, 2009 at 1:36 AM, Christophe Grand wrote: > > Hello Ryan, > > rzeze...@gmail.com a écrit : > > Either I've missed something, or Enlive *appears* to have problems > > handling comment tags. > > > Indeed. I pushed a fix, please tell me whether it works f

Re: Enlive questions

2009-05-05 Thread Christophe Grand
Hello Ryan, rzeze...@gmail.com a écrit : > Either I've missed something, or Enlive *appears* to have problems > handling comment tags. > Indeed. I pushed a fix, please tell me whether it works for you now. Thanks for the report. Christophe -- Professional: http://cgrand.net/ (fr) On Clojur

Re: Enlive questions

2009-05-05 Thread rzeze...@gmail.com
Either I've missed something, or Enlive *appears* to have problems handling comment tags. I was using Enlive against an already existing HTML file and kept getting the following exception (please note it is HTML 4.01 Strict and passed validation): java.lang.RuntimeException: java.lang.IllegalArg

Re: Enlive questions

2009-04-17 Thread David Nolen
Wow, thanks for the guidance, Enlive is improving at a rapid clip! ;) On Friday, April 17, 2009, Christophe Grand wrote: > > Updating to reflect last changes: > > (def snipgets >  (let [divs (select (html-resource "widget.html") >               [[:div (attr? :tiptree:widget)]])] >    (into {}

Re: Enlive questions

2009-04-17 Thread Christophe Grand
Updating to reflect last changes: (def snipgets (let [divs (select (html-resource "widget.html") [[:div (attr? :tiptree:widget)]])] (into {} (for [div divs] [(-> div :attrs :tiptree:widget) (snippet div [root] [widget] [:div.value]

Re: Enlive questions

2009-04-17 Thread Christophe Grand
select, snippet, at and template are macro sugar. If you _really_ want to use first-class selectors then you'll have to deal directly with states machines and use at*, select* and snippet* (I'm going to improve their usability). While selectors aren't first class, they can be parametrized (as

Re: Enlive questions

2009-04-16 Thread David Nolen
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] (le

Re: Enlive questions

2009-04-16 Thread David Nolen
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 th

Re: Enlive questions

2009-04-16 Thread Christophe Grand
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 a

Re: Enlive questions

2009-04-14 Thread Christophe Grand
David Nolen a écrit : > One early thought, would you like me to extend the number of examples? > I'm really getting into the nitty gritty of what's possible with > Enlive and it would be nice to have a relatively informative list of > possibilities distributed with the library vs. the single ex

Re: Enlive questions

2009-04-14 Thread Christophe Grand
David Nolen a écrit : > Sorry to bombard but I couldn't get attr? or attr= to work inside the > selector: > > (deftemplate my-app4 "app.html" > [widgets] > [:div '(attr? :tiptree:replace)] (content "bar")) > (apply str (my-app4 {})) > > (deftemplate my-app4 "app.html" > [widgets] > [[:div

Re: Enlive questions

2009-04-14 Thread David Nolen
Sorry to bombard but I couldn't get attr? or attr= to work inside the selector: (deftemplate my-app4 "app.html" [widgets] [:div '(attr? :tiptree:replace)] (content "bar")) (apply str (my-app4 {})) (deftemplate my-app4 "app.html" [widgets] [[:div '(attr? :tiptree:replace)]] (content "bar"))

Re: Enlive questions

2009-04-14 Thread Adrian Cuthbertson
I'm just starting out on Enlive - any examples added would be welcome. I'll also accumulate some documentation as I go through the learning curve. Thanks, Adrian. On Wed, Apr 15, 2009 at 5:05 AM, David Nolen wrote: > One early thought, would you like me to extend the number of examples? I'm > r

Re: Enlive questions

2009-04-14 Thread David Nolen
One early thought, would you like me to extend the number of examples? I'm really getting into the nitty gritty of what's possible with Enlive and it would be nice to have a relatively informative list of possibilities distributed with the library vs. the single example that's in there right now ;)

Re: Enlive questions

2009-04-14 Thread David Nolen
Great! I will play around with the new features and returns with some more informed feedback ;) On Tue, Apr 14, 2009 at 9:58 AM, Christophe Grand wrote: > > Hello David, > > David Nolen a écrit : > > Considering the above, I'm left wondering if it's possible to further > > eliminate these redundan

Re: Enlive questions

2009-04-14 Thread Christophe Grand
I pushed do->, attr=, attr? and snippets values as source to github http://github.com/cgrand/enlive/commits/right Christophe Grand a écrit : > Hello David, > > David Nolen a écrit : > >> Considering the above, I'm left wondering if it's possible to further >> eliminate these redundancies and

Re: Enlive questions

2009-04-14 Thread Christophe Grand
Hello David, David Nolen a écrit : > Considering the above, I'm left wondering if it's possible to further > eliminate these redundancies and make templates more reusable. I'm not > sure if this is what you had in mind for Enlive, but allowing > templates to be created without references to fi

Re: Enlive questions

2009-04-10 Thread David Nolen
Real quick thought: (deftemplate-generator template-generator [args] rule-vector transform-fn) Would produce a template generator. (def template-name (template-generator path-to-xml-or-file-or-xml-string)) Would produce a real template. (apply str (template-name arg1 arg2 arg3)) --~--~

Re: Enlive questions

2009-04-10 Thread David Nolen
This is great. I had thought that supporting some kind of partial template thing would be interesting, but that's actually just my poor logic at work ;) It seems like with the new version of Enlive I could do something like this: (deftemplate pageA-template path [] [[:div (attr? :tiptree:repl

Re: Enlive questions

2009-04-08 Thread Christophe Grand
Hi Tom, I'm sorry for this misfeature and, rejoice, it's gone from the ongoing redesign, there's now an explicit 'content function. The tildes are gone too! Christophe Tom Hickey a écrit : > Hi Christophe, > > I keep running into the same problem with elements getting replaced. > I'm trying t

Re: Enlive questions

2009-04-08 Thread Tom Hickey
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 te

Re: Enlive questions

2009-03-20 Thread Christophe Grand
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

Re: Enlive questions

2009-03-19 Thread Phil Hagelberg
Christophe Grand writes: > I see two advantages to using with-test: > * documentation/usage examples as you pointed out, Actually I meant that it's nicer for documentation to have the tests in a separate file since when you're trying to learn how to use the library initially, you don't care abo

Re: Enlive questions

2009-03-19 Thread Christophe Grand
Phil Hagelberg a écrit : > I notice you use with-test to mix your tests in together with your > implementation. This seems to be less common than storing the tests in > their own file; I'm wondering if you are happy with this approach? One > advantage of keeping things in their own file is that it

Re: Enlive questions

2009-03-19 Thread Phil Hagelberg
Christophe Grand writes: > I'm not quite happy with this behavior: I wanted to preserve the > brevity of setting content from a parameter without resorting to (text > my-parameter) but it makes things too irregular. This "feature" will > certainly go away as I'm planning a redesign. Yeah, I'm

Re: Enlive questions

2009-03-19 Thread Christophe Grand
Phil Hagelberg a écrit : > >From what I can tell the difference seems to be that it goes inside the > node if it's a string, and it replaces the node if it's a function call, > even if the function call results in a string. > > This behaviour seems really strange. I feel like maybe there's some >

Re: Enlive questions

2009-03-19 Thread Christophe Grand
Hi Phil! Phil Hagelberg a écrit : > I'm using the Enlive library, and so far I've been pretty impressed. The > way it separates templates out into their own files and doesn't allow > any logic to get mixed up with them is great. > Thanks for the kind words. > One thing I noticed is that its

Re: Enlive questions

2009-03-18 Thread Phil Hagelberg
Tom Hickey writes: > Regarding your first question, you can use (net.cgrand.enlive-html/ > escaped your-string) to skip the escaping of your strings. Thanks, that's helpful. I've also noticed one more oddity. Consider this snippet: (deftemplate index "foo/bar/template.html" [articles] [:div

Re: Enlive questions

2009-03-18 Thread Tom Hickey
Hi Phil, Regarding your first question, you can use (net.cgrand.enlive-html/ escaped your-string) to skip the escaping of your strings. Cheers, Tom On Mar 18, 3:47 pm, Phil Hagelberg wrote: > I'm using the Enlive library, and so far I've been pretty impressed. The > way it separates templates

Enlive questions

2009-03-18 Thread Phil Hagelberg
I'm using the Enlive library, and so far I've been pretty impressed. The way it separates templates out into their own files and doesn't allow any logic to get mixed up with them is great. One thing I noticed is that its templates escape all strings passed to them. In my case I have some strings