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

One-off no-content templates in content directory #693

Open
ge0ffrey opened this issue May 14, 2021 · 6 comments
Open

One-off no-content templates in content directory #693

ge0ffrey opened this issue May 14, 2021 · 6 comments
Milestone

Comments

@ge0ffrey
Copy link
Contributor

ge0ffrey commented May 14, 2021

I have a team.html page which list all our contributors.
That needs to get generated through an ftl template that reads from data/users.yml. There is no other html page like it, that would reuse this layout. It's a one-off template.

I have several other pages (download.html, documentation.html) that require a one-off template.
In fact, index.html is a natural one-off template. So is feed and archive (but post and tag are not because they create multiple output pages).

What I need to do now (workaround):

  1. Create a file content/community/team.html:
title=Team
type=community_team
status=published
~~~~~~
  1. In jbake.properties add:
template.community_team.file=community_team.ftl
  1. Create a file templates/community_team.ftl:
<#import "base.ftl" as base>
<@base.layout>
    <h1>${content.title}</h1>
    <#assign users = data.get('users.yml').data>
    <#list users as user>
       <p>${user.name}</p>
    </#list>
</@base.layout>

Proposal A) What I want to do:

  1. Create a file content/community/team.html.ftl:
title=Team
status=published
~~~~~~
<#import "base.ftl" as base>
<@base.layout title="Team">
    <h1>${content.title}</h1>
    <#assign users = data.get('users.yml').data>
    <#list users as user>
       <p>${user.name}</p>
    </#list>
</@base.layout>

The output filename is the template name without the ".ftl" suffix.

Similarly, content/blog/feed.atom.ftl and content/blog/feed.rss.ftl can create an Atom and RSS feed for a single website.

Requirements:

  • one-off templates should still be able to import macros and layout parent templates from the templates dir. A simple <#import "../../templates/normalBase.ftl" should work.
  • For one-off templates, content.body should not resolve to null, so these one-off templates can easily extend layout templates.
@LightGuard
Copy link

I think simply put, we need to be able to have template files parsed and rendered wherever they're found.

@jonbullock
Copy link
Member

Gotcha, need to work out how this fits into the pipeline (does this file get added to the content store as a piece of "content", does it actually need the metadata header etc.). Should have a better idea of the scope of work required then.

@jonbullock jonbullock added this to the v2.8.0 milestone Sep 1, 2021
@LightGuard
Copy link

It should be able to access the same information as a template. Is it a piece of content? I would say yes.

@ge0ffrey
Copy link
Contributor Author

ge0ffrey commented Jul 15, 2022

@jonbullock Any progress on this issue? It's the number one issue for us. Any clues on where to start if we want to fix this ourselves?

@jonbullock
Copy link
Member

@ge0ffrey No progress yet, all I can say is that it's still on my to do list.

tarilabs added a commit to tarilabs/matteomortari that referenced this issue Jan 1, 2024
tarilabs added a commit to tarilabs/matteomortari that referenced this issue Jan 1, 2024
* Option jbake-org/jbake#693

* Option using interpret

* wire talks.html from index
@tarilabs
Copy link
Contributor

tarilabs commented Jan 1, 2024

Hi, if this helps I've experimented with an alternative approach which works (with limitation of file-extension, below) but does not require the workaround to define a single template instance file per each one-offs.

You can see it in action here:

The downside: in /content the file is .html and not .ftl as the file extensions which can be baked from content seems to me is fixed (and due to constraint as detailed here)

In other words I edit the /content/oneoff.html as if it's a .ftl and then I wire it into a single FTL template designed on purpose, which interprets the content body as if it was part of the originating FTL.

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

No branches or pull requests

4 participants