Skip to content

using jinja extends to create a single file #1465

Answered by sisp
awesomescot asked this question in Q&A
Discussion options

You must be logged in to vote

I think you're looking for Jinja inheritance and a Jinja include with a dynamic filename. Perhaps like this?

  • includes/config/_base.yaml.jinja contains your base config, perhaps with some Jinja blocks as extension hooks.
  • includes/config/<app_name>.yaml.jinja extend _base.yaml.jinja, e.g.:
    {% extends "includes/config/_base.yaml.jinja" %}
    # your app specific extension
    
  • template/config.yaml.jinja includes the app specific config content:
    {% include "includes/config/" ~ app_name ~ ".yaml.jinja" %}
    Here, I assume you set _subdirectory: template/ in copier.yml, otherwise you need to make sure to exclude the includes/ dir from being copied, and I assume you have a Copier question variable app_name

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
1 reply
@awesomescot
Comment options

Comment options

You must be logged in to vote
3 replies
@awesomescot
Comment options

@sisp
Comment options

@awesomescot
Comment options

Answer selected by awesomescot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants