Hacker News new | ask | show | jobs
by alaaalawi 2001 days ago
Just curious. I went and skimmed through the handlebarsjs link. I'm used to cl-who and can not see what the js lib does have that is not possible or harder in cl-who. Side note: with a small macro you can start defining your own streamlined components and special tags. akin to having your abstractions. Also l'm taking a course in HTML5+CSS and use this additionally to avoid being drawned in the usual characteristic boilerplate text.
2 comments

Just curious. I went and skimmed through the handlebarsjs link. I'm used to cl-who and can not see what the js lib does have that is not possible or harder in cl-who.

They are very different styles, though. With cl-who you write code that mimics the structure of HTML and that code outputs HTML. With Handlebars etc. you write your HTML in HTML and embed code in it. Some prefer one over the other.

I wrote a templating library that was used for a Slack close we developed a number of years back.

It parses the HTML with embedded code, and generates a Lisp function which is compiled on the fly thanks to Lisp giving runtime access to the compiler. Whenever the source file is changed, the code is regenerated and compiled.

Other languages do the same, but in those cases they have to generate source code and call the compiler as an external program, and then load the generated code into the running program using dynamic linking. The Lisp approach is much more efficient.

Thanks to the quality of SBCL, the templates execute with native performance, which is something very few other solutions do.

The project is unfortunately not documented, but the code is available here: https://github.com/lokedhs/lofn

I am actually using handlebars along with helpers https://github.com/helpers/handlebars-helpers to automatically generate sql, golang, json and jsx. cl-who is only for markup. What i found useful in handlebars is ability to define inline function templates and use them in template. I am missing cl macro's which would automate my workflow even more so asking if something like this is available in cl.