Skip to content

Jinja2 templating #324

Answered by yaythomas
jpdrsn asked this question in Q&A
Jun 14, 2023 · 1 comments · 3 replies
Discussion options

You must be logged in to vote

Hi @jpdrsn,

There isn't a built-in a step for jinja, and there never was.

You can however make your own one, it's easy, promise!

If you have a custom .py file in your pipeline directory in a steps directory, like ./steps/jinja.py:

import logging
from pathlib import Path

from pypyr.context import Context
from pypyr.utils.asserts import assert_key_has_value

from jinja2 import Environment, FileSystemLoader

# getLogger will grab the parent logger context, so your loglevel and
# formatting automatically will inherit correctly from the pypyr core.
logger = logging.getLogger(__name__)


def run_step(context: Context) -> None:
    # friendly error msg if pipeline tries to use this without jinj…

Replies: 1 comment 3 replies

Comment options

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

@jpdrsn
Comment options

@yaythomas
Comment options

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