Can v0.4.1: server-side HTML components for Crystal

Hi. I am working on Can, currently a pre-1.0 server-side HTML component system for Crystal.

The basic idea is to write components as HTML in “cans” (.can files) and compile those templates to Crystal before the app runs. It is not a JavaScript framework, and there is no runtime template parser.

Can currently supports:

  • component defs
  • slots
  • scoped CSS
  • literal quoted attributes
  • expression attributes
  • template-level <.use>, loading can in can.
  • can-render, a small CLI for rendering a single .can file in static tests/experiments

Should work well for Crystal SSR projects, Kemal, Grip or HTTP::Server apps, and exploring an HTML-first component model in Crystal.

The important caveats: pre-1.0, I am not yet presenting it as production-ready infrastructure.
and can-render tool is not a full static site generator; it renders one .can file. A broader static-site workflow is a natural direction, but not something I haven’t dug into yet. In the mean time works for served site which is it main use case.

Links:

I would especially like feedback on:

  • whether the README explains the value quickly enough
  • whether the component model feels natural for Crystal
  • what example would make this easiest to evaluate
  • would a full static site generation be good addition
  • any and all other suggestions, issues, etc.

And, yes, I vibe code these days. But I do make an effort to keep the project focus small, and manually review the source as I have time. Plus, super helpful is Crystal itself – it lends itself to cleaner code in general.

Thanks.

Oh nice.

Well, ever since David presented Rails, “here’s how you build a blog” has been the goto example for web-frameworks. As this isn’t quite a full framework, the static site generator sounds like the best way to show off the strengths of Can.

OT: I’ve thrown myself at the LLM with my own little, wait for it, web-framework. The objective has been getting used to using the LLM and trying out some wild ideas in practice. I’d never got as far as I have with my limited free time on my own, so there’s that. I wouldn’t call it “vibe-coding” though, as even though it’s 99% written by Gemini, I pour over each diff and occasionally take it upon myself to rewrite the method that it can’t get right.