#๐Ÿ”’ JInja2 render with Trim

4 messages ยท Page 1 of 1 (latest)

modern needle
#

Hello, I am rendering multiple files, because if that I need to have trim enabled.
But when I render this with trim:

# API
PROJECT_NAME={{ project_name }}
API_V1_STR=/api/v1
DOMAIN=localhost
ENVIRONMENT=local
BACKEND_CORS_ORIGINS="*"
API_PORT=8000

# Database
POSTGRES_SERVER={% if "docker" in features %}db{% else %}localhost{% endif %}
POSTGRES_PORT=5432
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
POSTGRES_DB=fastapi

I get this:

# API
PROJECT_NAME=
API_V1_STR=/api/v1
DOMAIN=localhost
ENVIRONMENT=local
BACKEND_CORS_ORIGINS="*"
API_PORT=8000

# Database
POSTGRES_SERVER=localhostPOSTGRES_PORT=5432
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
POSTGRES_DB=fastapi

Because there will be no new line after the {% endif %}
How would I render this correctly with Trim enabled?

simple zealotBOT
#

@modern needle

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

simple zealotBOT
#

@modern needle

Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.