Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I've written some Clojure code ( <a href="https://gist.github.com/3729307" rel="nofollow">https://gist.github.com/3729307</a> ) that allows to interpolate any map value into a template, in probably the fastest possible way (see below) <strong>IF</strong> the template is known at compile-time. </p> <p>It doesn't use the same template syntax (although it could be adapted for that), but I think it still can be used to solve the exact same problem.</p> <p>With this solution, the code would have to be rewritten like...</p> <pre><code>; renderer-fn is defined in https://gist.github.com/3729307 (time (dotimes [n 100] ((renderer-fn "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elit nisi, egestas et tincidunt eget, " (:foo %) " mattis non erat. Aenean ut elit in odio vehicula facilisis. Vestibulum quis elit vel nulla interdum facilisis ut eu sapien. Nullam cursus fermentum sollicitudin. Donec non congue augue. " (:bar %) " Vestibulum et magna quis arcu ultricies consectetur auctor vitae urna. Fusce hendrerit facilisis volutpat. Ut lectus augue, mattis " (:baz %) " venenatis " (:foo %) "lobortis sed, varius eu massa. Ut sit amet nunc quis velit hendrerit bibendum in eget nibh. Cras blandit nibh in odio suscipit eget aliquet tortor placerat. In tempor ullamcorper mi. Quisque egestas, metus eu venenatis pulvinar, sem urna blandit mi, in lobortis augue sem ut dolor. Sed in " (:bar %) " neque sapien, vitae lacinia arcu. Phasellus mollis blandit commodo.") {:foo "HELLO" :bar "GOODBYE" :baz "FORTY-TWO"}))) ; =&gt; "Elapsed time: 1.371 msecs" </code></pre>
 

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