>
> I would like to evaluate other methods which may involve:
> -parsing hidden strings in the html code
>
The way that I've been doing this, for better or worse, has been to insert
a Javascript function call into the HTML output by my server, like:
<script type="text/javascript">
$(function() {my_cljs_ns.initialize('data');});
</script>
Where 'data' is some clojure datastructure that has been run through pr-str
and had single quotes escaped. The clojurescript function called by the
generated javascript has to be marked with :export to make this work. When
called, it calls read-string on its first argument.
This seems more or less equivalent to just using a hidden form field. I
don't really see much of an advantage either way. This approach has been
working great for me so far.
> -compiling or retrieving from cache, javascript code generated from
> clojurescript serverside with the data literals in javascript form already,
> no parsing of clojurescript needed.
>
Why are you trying to avoid parsing the clojurescript client-side? Are you
working with a very large data structure? Dynamically compiling the form
to javascript on the server side is going to be very expensive, although I
guess if it's very cache-friendly it might work out well.
Be aware that if you're using the compiled clojurescript approach, and are
using advanced optimizations, that you'll need to make careful use of
:export and possibly even :externs to make the pre-compiled and
dynamically-compiled javascript work together.
Using the pr-str/read-string approach is likely to be *much* simpler than
this, and is definitely the approach I'd recommend.
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en