Hi Evan,

I think Hiccup is a also a good starting point for this. In fact
99% of the port is already working. The last thing I struggle
with is actually only cosmetics, like carrying over the meta data
with the arglist and documentation.

Why do you think it is impossible to have the same API in Clojure
and ClojureScript? If you look at the header of the following
file you can see that it's using exactly Hiccup's API (except :use-macros).

https://github.com/r0man/hiccup/blob/clojurescript/test/cljs/hiccup/test/page.cljs

Your lein-cljsbuild will take care of modifiying the :use-macros
clause in the namespace declaration when used in crossover files.
But maybe I missed something?

Roman.


On Saturday, April 7, 2012 10:22:58 PM UTC+2, Evan Mezeske wrote:
>
> I think crate is about the closest that you're going to be able to get to 
> hiccup in practice.  ClojureScript macros are written in Clojure, and thus 
> have to come from separate namespaces from the rest of the ClojureScript 
> code.  So, it is not possible to just port hiccup to ClojureScript on a 
> var-by-var basis; the namespaces will always have to be slightly different. 
>  The only way you could have hiccup provide the exact same API on both 
> Clojure and ClojureScript would be to modify the Clojure API so that it is 
> conducive to being implemented in ClojureScript.
>
> Aside from the impossibility of keeping the API identical in 
> ClojureScript, I don't see why it should not be possible to have more of 
> the templating work done at compile-time via macros.  IMHO, though, crate 
> would be a good starting point for that, rather than creating yet another 
> hiccup-in-clojurescript clone.
>
> -Evan
>
> On Saturday, April 7, 2012 1:03:39 PM UTC-7, r0man wrote:
>>
>> Hi Chris,
>>
>> yes I have seen crate. But I wanted something where I can share
>> the same view code and use it on the client and the server and
>> use the same api. I also think Hiccup's aproach to generate html
>> strings at compile time is quite nice. That way the
>> deconstruction of [:div#id.class] stuff can be done at compile
>> time.
>>
>> Thanks anyway. I'm looking at add-optional-attrs in your lib.
>> Maybe that can get me further ...
>>
>> Roman.
>>
>>
>> On Saturday, April 7, 2012 9:32:38 PM UTC+2, Chris Granger wrote:
>>>
>>> Have you seen Crate? 
>>>
>>> http://github.com/ibdknox/crate 
>>>
>>> On Apr 7, 1:18 pm, r0man <roman.sche...@burningswell.com> wrote: 
>>> > Hello ClojureScripters, 
>>> > 
>>> > I started to port the Hiccup library to ClojureScript. The goal 
>>> > is to have a port of Hiccup that has exactly the same api. This 
>>> > would make it possible to write views once (provided no platform 
>>> > specific code is used), and run them on the server with Clojure 
>>> > and on the client with ClojureScript. 
>>> > 
>>> > At the moment I copied most of the Clojure files and made some 
>>> > modifications where necessary. The whole Hiccup testsuite runs 
>>> > fine in the browser, as well in a headless v8 session. 
>>> > 
>>> > However I have one last hurdle to take. Most macros I can use in 
>>> > Clojure and in ClojureScript with some minor adjustments, except 
>>> > the "defelem" macro in the "hiccup.def" namespace. To get this 
>>> > one running in ClojureScript I had to change it's implementation 
>>> > and move it to the "hiccup.macro" namespace. 
>>> > 
>>> > The problem with this macro is, that it uses the alter-var-root 
>>> > fn to add additional functionality to the given fn. As far as I 
>>> > can tell there is no alter-var-root in ClojureScript. I got the 
>>> > code running by using set! in the ClojureScript version. 
>>> > 
>>> > The original Clojure macro: 
>>> > 
>>> > https://github.com/r0man/hiccup/blob/clojurescript/src/clj/hiccup/def... 
>>>
>>> > 
>>> > The ClojureScript macro: 
>>> > 
>>> > https://github.com/r0man/hiccup/blob/clojurescript/src/clj/hiccup/mac... 
>>>
>>> > 
>>> > Is anyone aware of a solution that would share the same code and 
>>> > work in both cases? Are there plans to add alter-var-root to 
>>> > ClojureScript as well? 
>>> > 
>>> > Thanks, Roman.
>>
>>

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