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

Refactor/nunjucks ification #302

Merged
merged 30 commits into from
Mar 25, 2019
Merged

Refactor/nunjucks ification #302

merged 30 commits into from
Mar 25, 2019

Conversation

sturobson
Copy link

@sturobson sturobson commented Mar 14, 2019

  • swap out the use of handlebars into nunjucks in fractal.js
  • transpose existing handlebars helpers to nunjucks
  • change all the patterns from .hbs to .nunj

@khawkins98 feel free to add and check off these.

@khawkins98
Copy link
Contributor

Having a look at this branch. Merged in the latest edits from develop

@sturobson
Copy link
Author

hmm. I thought I added a 'list' for this in the description :(

@khawkins98
Copy link
Contributor

A few differences:

  • Referencing YAML variables, if we have hyphens (vf-lede-text):
    • Out:<p class="vf-lede">{{{vf-lede-text}}}</p>
    • In: <p class="vf-lede">{{ _self.context["vf-lede-text"] }}</p>
    • Doesn't change for {{ vf_lede }}
    • So I think we may need to update some YAML variables accordingly
  • Referencing patterns:
    • Out: {{> '@vf-content'}}
    • In: {% render '@vf-content' %}
  • Passing variables to patterns:
    • Out: {{> '@vf-lede' vf-lede-text=vf-intro-lede}}
    • In: {% render '@vf-lede', {"vf-lede-text": vf_intro_lede} %}

And then lots of the standard nunj differences with hbs

I think the big question is what are we gaining? Some notes:

  • 11ty could use hbs or nunj ... nunjucks could make some templating things easier
  • we might be able to do some fancier things in our pattern library with nunjucks, I think

Really, it's probably a bit of a tossup? It's probably a question of "Do we like Nunj more the Handlebars?"

@khawkins98
Copy link
Contributor

khawkins98 commented Mar 22, 2019

Rethinking my closing line above:

Really, it's probably a bit of a tossup? It's probably a question of "Do we like Nunj more the Handlebars?"

Have investigated further over the past few days and had three areas that encourage me on this:

  • I've had some initial success at (crudely) grafting the fractal (Nunj) templating pattern engine to extend 11ty ... that means we can npm install pattern and then just use them as templates (including access to pattern Yaml) 🎈
    • There's also a whole world of possibility about dynamically compiling only the sass needed for a static site
    • related to this ticket specifically: I'm less confident I could graft fractal into 11ty using Handlebars templates
  • I've updated this branch to no longer use a theme of frctl/mandelbrot, but rather use its own theme outright. that allows a lot more customisation, including using .njk over .nunj
    • Potentially we could use 11ty for our pattern library, but that requires a little more thought
  • Best for last: nunjucks is, of course, a much richer templating engine and resolves a lot of the consternation we were getting in making real templates (see: Feature/variant modifiers Feature/variant modifiers #310)
    • You can see the differences in this commit: da64367

So, with all that in mind:

  1. I do think we should go with Nunjucks
  2. We'll need to get the Nunjucks templates into alpha.4 (Thursday the 28th) so the new Nunjucks templates go up to npm
  3. Once the nunj template are in npm we can further explore the use of 11ty

All of the patterns are working in fractal now ... with the exception of the two custom Handlebars helpers, I'm still trying to understand the syntax there. But hope to have that today at some point.

In many ways this isn't urgent, but I don't think we should let it sit around too long as the merge request will get complex fast.

@sturobson sturobson marked this pull request as ready for review March 25, 2019 08:54
This will also help with our documentation efforts:
```
{% set context = '@vf-heading' | patternContexts %}
```
@khawkins98 khawkins98 self-requested a review March 25, 2019 12:52
@khawkins98 khawkins98 added this to the v2.0.0-alpha.4 milestone Mar 25, 2019
@sturobson sturobson merged commit 92fa113 into develop Mar 25, 2019
@sturobson sturobson deleted the refactor/nunjucks-ification branch March 25, 2019 13:05
@sturobson
Copy link
Author

Boom

@khawkins98 khawkins98 mentioned this pull request Mar 25, 2019
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants