-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Thanks for your work #39
Comments
@pcav excellent, very interesting company! I am glad that you find the template useful. A new release will be out in a few days, featuring support for bibliography... you might find that useful too. I have taken a look at your code, and I think it can be improved. You should consider using Jinja2 which is a template engine for Python, rather than generating the .tex file one line at a time using Best! |
Thanks a lot. Yes, we're sure it can be improved in several respects. We'll try to grneralize it. Thanks for the suggestion. |
Hi @gmazzamuto we are working on other improvements (e.g. DB template). What would be your suggestions to use Jinja to improve the code? Do you have some examples? |
@ghtmtt Here is a minimal example. With Jinja2 you can do something like this: Template file \documentclass[english,a4paper]{europasscv}
\usepackage[english]{babel}
\ecvname{\PYVAR{pi.name}}
\ecvaddress{\PYVAR{pi.address}}
\begin{document}
Hello, my name is \PYVAR{pi.name} and this is my CV:
\begin{europasscv}
\ecvpersonalinfo
\end{europasscv}
\end{document} Python script to render the template: from jinja2.nativetypes import NativeEnvironment, Environment
from jinja2.loaders import FileSystemLoader
env = Environment(
loader=FileSystemLoader('.'),
variable_start_string='\PYVAR{',
variable_end_string='}',
)
template = env.get_template('template_cv.tex')
# Python variable to hold personal information
pi = {
'name': 'Katie Smith',
'address': '12 Strawberry Hill, Dublin 8 Éire/Ireland',
}
template.stream(pi=pi).dump('output.tex') # render template to file
# or, equivalently, if on needs the rendered template in a Python variable
rendered = template.render(pi=pi)
with open('output2.tex', 'w') as f:
f.write(rendered) Note that with Jinja2 the default variable syntax in the template is |
Many thanks @gmazzamuto for the code snippet. From what I see you are defining a template but I'll still looping some dictionary values (as it is for now in my script). So the main difference is in using |
Thanks @gmazzamuto ! |
I know I'm abusing this bugtracker, but we just want to thank you for your template, that we are using with success for our website https://www.faunalia.eu/ through our scripts https://gitlab.com/faunalia/cv_pg_generator
Thanks!
The text was updated successfully, but these errors were encountered: