Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transition away from Handlebars for style guide templates? #44

Open
tylersticka opened this issue Jan 30, 2020 · 1 comment
Open

Transition away from Handlebars for style guide templates? #44

tylersticka opened this issue Jan 30, 2020 · 1 comment

Comments

@tylersticka
Copy link
Member

We've discussed adding support for other templating languages for patterns (#22), but this issue is specifically about what we're using for this project's layouts, templates, etc.

I've noticed over the course of some recent projects and making modifications to this one that Handlebars has a number of shortcomings:

  • It doesn't support async helpers or functions. More and more libraries are writing asynchronous features by default these days, so that limits what helpers we can expose to the style guide.
  • It doesn't support relative paths in includes.
  • It doesn't have a unique filter syntax, resulting in messy {{nested (shortcodes (of (doom)))}}
  • It doesn't support conditionals that are more complex than truthy/falsy checks.
  • Its loop syntax can be confusing since it assigns the current value to . or @this (whereas most other template engines cast the current element to a property name like JavaScript does).
  • While it supports extensible blocks in partials (@gerardo-rodriguez wrote a great article on this), its syntax for doing so is not very discoverable.
  • It is not fully supported in certain Eleventy Frontmatter properties (such as pagination).

Looking at Eleventy's built-in template languages, I can't help but gaze enviously at the list of supported Nunjucks features… 👀

Especially interested in @Paul-Hebert's opinion as the originator of this repo!

@Paul-Hebert
Copy link
Member

Good suggestion @tylersticka. That list of Nunjucks features and Handlebars caveats is pretty convincing! I'd definitely be interested in switching.

I know that in a recent project, we'd considered Nunjucks and went back to Handlebars for a couple reasons:

  1. We struggled to find a simple way to automatically register Nunjucks includes and macros. (I think we were pressed for time though, with a more flexible timeline I'm sure we could figure out a good solution.)
  2. Writing includes and macros in Nunjucks is more verbose than in Handlebars (this may be less of a concern, when writing a boilerplate tool like this, than when quickly spinning up patterns.)

I think both of those previous concerns shouldn't be show-stoppers here, so I'd be happy to experiment with switching to Nunjucks. Whoever takes on this work should coordinate with other devs who have work in progress so everyone's aware what's going on as this is a pretty big change.

I can look into this soon, but if anyone else is interested and would prefer to take a crack at it themselves they're more than welcome 🙂

Thanks Tyler!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants