Hacker News new | ask | show | jobs
by escherize 3775 days ago
Really, I think Hiccup is the best solution in this space.

Prefer logic-less functions to output html strings? Hiccup has this use case covered. This is all stock Clojure[script], not a templating language:

    (def foo [:h2 "something cool"])
    (hiccup.core/html foo) ;;=> "<h2>something cool</h2>"
Plus there's plenty of ways to quickly build up a bootstrap (, etc) page.

    (defn bootstrap-page [hiccup-form]
     (hiccup.page/html5 
      (hiccup.page/include-js "link-to-jquery.js" 
                              "link-to-bootstrap.js")
      (hiccup.page/include-css "link-to-bootstrap.css")
      hiccup-form))
BTW, there are some interactive examples at http://hiccup.space
3 comments

I'm going a tiny step further with the XML/HTML generation solution in functional Perl [1]: provide actual functions to instantiate HTML (or defined XML) elements, instead of relying on arrays. That allows for passing them directly to higher-order functions like map (and it also gives elements a proper type).

  my $rows= list(list(1,2,3), list(4,5,6));
  HTML(BODY(TABLE($rows->map(fun($row) { TR($row->map(*TD)) }))))->string
  # => '<html><body><table><tr><td>1</td><td>2</td><td>3</td></tr><tr><td>4</td><td>5</td><td>6</td></tr></table></body></html>'

  ref HTML()
  # => 'PXML::PXHTML';
[1] http://functional-perl.org/
CL-WHO is an often forgotten grandfather of Hiccup - http://weitz.de/cl-who/

Also here's a quick list of some other CL-WHO alternatives - http://stackoverflow.com/questions/671572/cl-who-like-html-t...

Hiccup is wonderful, almost makes it painful to go back to jade/erb/jinja/etc after working on a project with hiccup.