If-Then

{% if var %} Some text. {% endif %}

Test Equality

== to test equality

Apartment {% if apt == "2nd Floor" %}(and terrace){% endif %} {{ apt }} at 415 83rd Street,  Brooklyn, NY 11209
{%p endif %}

Date: One Year - One Day

from datetime import datetime
from dateutil.relativedelta import relativedelta

your_date_string = "April 1, 2012"
format_string = "%B %d, %Y"

datetime_object = datetime.strptime(your_date_string, format_string).date()
new_date = datetime_object + relativedelta(years=1) - relativedelta(days=1)
new_date_string = datetime.strftime(new_date, format_string).replace(' 0', ' ')

print(new_date_string)

# 4/28/2021
# From:
# - https://stackoverflow.com/questions/15741618/add-one-year-in-current-date-python
# - https://www.tutorialspoint.com/How-can-I-subtract-a-day-from-a-Python-date#:~:text=You%20can%20subtract%20a%20day%20from%20a%20python,to%20subtract.%20Then%20subtract%20it%20from%20the%20date.

Variables: Case Sensitive

Variables in docx template are case sensitive. So, {{ tenant_name }} and {{ TENANT_NAME }} are separate variables.

Number: Formatted with , and .00

rent = 2000
rent_2d = "{:,.2f}".format(rent)
print(rent_2d)

yearly = rent * 12
yearly_2d = "{:,.2f}".format(yearly)
print(yearly_2d)