Thanks everyone for your help.

The route that I choose to go is a mix of selmer for the predefined mostly 
static things and quoting with pprints code-dispatch.
Very useful, didn't know that :-)

Best Regards,
Sven

Am Donnerstag, 9. April 2015 21:45:41 UTC+2 schrieb Devin Walters (devn):
>
> To Leon's point above, that looks like:
>
> 12345678910111213
>
> (require '[clojure.pprint :as pp])
>  
> (pp/with-pprint-dispatch pp/code-dispatch
>   (pp/pprint 
>     (read-string "(defn foo [xs] (apply str (reverse (str (apply + (for [y 
> (filter (fn [x] (= x 1)) xs)] (inc y)))))))")))
>  
> =>
> nil
> (defn foo [xs]
>   (apply
>     str
>     (reverse
>       (str (apply + (for [y (filter (fn [x] (= x 1)) xs)] (inc y)))))))
>
>
> On Thu, Apr 9, 2015 at 2:34 PM, Leon Grapenthin <grapent...@gmail.com 
> <javascript:>> wrote:
>
>> You can use 
>> https://clojure.github.io/clojure/clojure.pprint-api.html#clojure.pprint/with-pprint-dispatch
>>  
>> with 
>> https://clojure.github.io/clojure/clojure.pprint-api.html#clojure.pprint/code-dispatch
>>  
>> to achieve that.
>>
>> On Wednesday, April 8, 2015 at 8:14:02 PM UTC+2, Sven Richter wrote:
>>>
>>> Hi,
>>>
>>> @Tassilo Thank you. Your example works nicely the way I imagined it.
>>>
>>> However, I want to generate human readable code and I want line breaks 
>>> and nice formatting and things. I will also try a templating language. 
>>> lein-template uses moustache or something. I will see how that works out.
>>>
>>> Thanks everyone for your suggestions,
>>> Sven
>>>
>>> Am Mittwoch, 8. April 2015 19:25:23 UTC+2 schrieb James Reeves:
>>>>
>>>> On 8 April 2015 at 14:20, Sven Richter <sve...@googlemail.com> wrote:
>>>>>
>>>>> I want to create clojure source files with some code and a namespace 
>>>>> and everything else what is useful for some source code.
>>>>> What I am looking for is a templating language for clojure code, is 
>>>>> there something like this already? What would be the most idiomatic way 
>>>>> to 
>>>>> do that besides just writing strings into a file?
>>>>>
>>>>
>>>> What's the purpose? If it's just to generate some Clojure code that 
>>>> will never be read by a human, then you can use Clojure's backtick syntax 
>>>> with the pr-str function. If it's to generate human-readable code, then 
>>>> you're probably best using a text templating language.
>>>>
>>>> You may also want to look at Leiningen templates or lein-generate.
>>>>
>>>> - James
>>>>
>>>  -- 
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clo...@googlegroups.com 
>> <javascript:>
>> Note that posts from new members are moderated - please be patient with 
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+u...@googlegroups.com <javascript:>
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to clojure+u...@googlegroups.com <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to