Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You would like to use the <a href="http://richhickey.github.com/clojure-contrib/str-utils-api.html#clojure.contrib.str-utils/re-gsub" rel="nofollow">re-gsub</a> like this:</p> <p>(require 'clojure.contrib.str-utils) ;;put in head for enabling us to use re-gsub later on</p> <p>(clojure.contrib.str-utils/re-gsub #"\newline" "&lt;br&gt;&lt;br&gt;" your-string-with-todos-separated-with-newlines)</p> <p>This last line will result in the string you like. The require-part is, as you maybe already know, there to enable the compiler to reach the powerful clojure.contrib.str-utils library without importing it to your current namespace (which could potentially lead to unnescessary collisions when the program grows). </p> <p>re- is for reg-exp, and lets you define a reg-exp of the form #"regexp", which to replace all instances that is hit by the regexp with the argument afterwards, applied to the third argument. The \newline is in this case clojures way of expressing newlines in regexps as well as strings and the character we are looking for.</p> <p>What I think you really wanted to do is to make a nifty ordered or unordered list in html-format. These can be done with [hiccup-page-helpers][2] (if you don't have them you probably have a compojure from the time before it got splited up in compojure, hiccup and more, since you use the html-function).</p> <p>If you want to use hiccup-page-helpers, use the command re-split from the clojure.contrib.str-utils mentioned above in this fashion:</p> <p>(use 'hiccup.page-helpers) ;;watch out for namespace collisions, since all the functions in hiccup.page-helpers got into your current namespace.</p> <p>(unordered-list (clojure.contrib.str-utils/re-split #"\newline" your-string-with-todos-separated-with-newlines))</p> <p>which should render a neat <br>&lt;ul&gt; <br>&nbsp;&lt;li&gt;todo-item1&lt;/li&gt; <br>&nbsp;&lt;li&gt;todo-item2&lt;/li&gt; <br>&lt;/ul&gt;</p> <p>(and yes, there is an ordered-list command that works the same way!)</p> <p>In the last line of clojure code above, all you todos gets into a (list "todo1" "todo2") which is immediately consumed by hiccup.page-helpers unordered-list function and is there converted to an html-ized list.</p> <p>Good luck with compojure and friends!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload