Skip to content

Commit

Permalink
compute last updated date on python side
Browse files Browse the repository at this point in the history
  • Loading branch information
sinaatalay committed Oct 7, 2023
1 parent 0c9ea2a commit 476528b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion rendercv/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""RenderCV package.
r"""RenderCV package.
It parses the user input YAML/JSON file and validates the data (checks spelling mistakes, checks if the dates are consistent, etc.). Then, with the data, it creates a $\LaTeX$ file and renders it with [TinyTeX](https://yihui.org/tinytex/).
"""
19 changes: 18 additions & 1 deletion rendercv/rendering.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ def make_it_bold(value: str, match_str: str) -> str:
else:
return value


def make_it_underlined(value: str, match_str: str) -> str:
"""Make the matched parts of the string underlined.
Expand Down Expand Up @@ -156,6 +157,7 @@ def make_it_underlined(value: str, match_str: str) -> str:
else:
return value


def make_it_italic(value: str, match_str: str) -> str:
"""Make the matched parts of the string italic.
Expand Down Expand Up @@ -186,6 +188,19 @@ def make_it_italic(value: str, match_str: str) -> str:
else:
return value


def print_today() -> str:
"""Return today's date.
Returns:
str: Today's date.
"""
from datetime import date

today = date.today()
return today.strftime("%B %d, %Y")


def render_template(data):
"""Render the template using the given data.
Expand Down Expand Up @@ -226,7 +241,9 @@ def render_template(data):
environment.filters["make_it_underlined"] = make_it_underlined
environment.filters["make_it_italic"] = make_it_italic

output_latex_file = template.render(design=data.design.options, cv=data.cv)
output_latex_file = template.render(
design=data.design.options, cv=data.cv, today=print_today()
)

# Create an output file and write the rendered LaTeX code to it:
output_file_path = os.path.join(os.getcwd(), "tests", "outputs", "test.tex")
Expand Down
2 changes: 1 addition & 1 deletion rendercv/templates/classic.tex.j2
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
\newcommand{\placelastupdatedtext}{% \placetextbox{<horizontal pos>}{<vertical pos>}{<stuff>}
\AddToShipoutPictureFG*{% Add <stuff> to current page foreground
\put(\LenToUnit{\paperwidth-0.5cm},\LenToUnit{\paperheight-0.5cm}){\vtop{{\null}\makebox[0pt][c]{
\small\color{gray}\emph{Last updated on \printdayon\today} \hspace{\widthof{Last updated on \printdayon\today}}}}}%
\small\color{gray}\emph{Last updated on <<today>>} \hspace{\widthof{Last updated on <<today>>}}}}}%
}%
}%
Expand Down

0 comments on commit 476528b

Please sign in to comment.