Bart Van Loon
Bart Van Loon

Reputation: 1510

Render a Page object from a template

In a Lektor website, I'm facing the following problem:

Now the question is: how do I get to render these child pages inside facts.html?

I know this is possible by transforming the fact.html template into a macro that can be called from facts.html, but I was hoping there would be a more elegant way of achieving the same result.

Is there a render-like method available for Page objects?

Upvotes: 0

Views: 118

Answers (1)

lupdidup
lupdidup

Reputation: 311

I can not quite follow your setup. You said you have a .facts attribute that is of type Flow. However, you perform a query on /facts to get its children which suggests that these are sub-pages and not flow blocks. So.. I am not sure what you try to achieve, but:

You can have template files for flow-blocks, you just have to place them in e.g., templates/blocks/fact.html. If you do that, you can just print out the flow attribute itself (<div>{{ this.facts }}</div>) and all individual flow-blocks will be drawn with the flowblock template.

EDIT:

You asked to display another (full) page template into a flow-block type:

{% set other = site.get('/projects') %}
{{ site.env.render_template('facts.html', pad=other.pad, this=other)|safe }}

Upvotes: 1

Related Questions