question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support Jekyll-like includes: {% include {{ page.my_variable }} %}

See original GitHub issue
{% include prefix/{{ page.my_variable }}/suffix %}

Just like it’s included in Jekyll: https://jekyllrb.com/docs/includes/#using-variables-names-for-the-include-file

It’s basically an improved and more flexible version of dynamic partials.

I tried working this limitation around in fs.readFile(path) interface, but unfortunately, the spec is too limited. The only argument passed is prefix/{{ page.my_variable }}/suffix. Liquid context is lost, so I cannot run this string through the Liquid engine again for processing to read the correct file.

If the spec of fs is modified to fs.readFile(path, context) or there’s this.liquidContext, it would make my use case trivial to implement in fs, unless you want to make Jekyll-like dynamic includes an official part of Liquidjs.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
Nowakercommented, Dec 18, 2021

@harttle Implementation & docs are perfect, thank you! Thanks a lot! I’ll promptly update and remove our readFile hackery 😃

In the meantime, my project - rendering Jekyll sites in Gatsby - is moving forward! We have almost everything implemented already… Very exciting.

2reactions
harttlecommented, Dec 17, 2021

I can try make this happen. If there’s no perf regression I think we can ship an updated include. Otherwise, extending include would be better compared to rendering templates in FS.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Includes | Jekyll • Simple, blog-aware, static sites
Includes. The include tag allows you to include the content from another file stored in the _includes folder: {% include footer.html %}.
Read more >
Master file - serhii.net
Do I want to get a clear picture of all the various levels of escaping, including globs, backticks, backslashes etc. happening in the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found