From cb289f659b8d5752eece21d1eaff537efcff4abf Mon Sep 17 00:00:00 2001 From: L3D Date: Tue, 7 Mar 2023 22:14:08 +0100 Subject: [PATCH] improve plugin to fix exactly my template --- lektor_render_template.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/lektor_render_template.py b/lektor_render_template.py index af25529..fc56d5c 100644 --- a/lektor_render_template.py +++ b/lektor_render_template.py @@ -20,14 +20,25 @@ def generate_from_template(inputname, **options): # Prepare Variables rendered_title = f"Ansible Role: {inputname}" - rendered_sizes = f"width=\"{int(118+(len(inputname)*6))}\" height=\"20\"" - orange_box_width = str(int(20+len(inputname)*6)) - orange_position = str(int(114+(len(inputname)*6))) + rendered_sizes = f"width=\"{int(132.5+(int(len(inputname)/2)*10))}\" height=\"20\"" + orange_box_width = str(int(5+len(inputname)*6)) + orange_position = str(int(50+(len(inputname)*6))) + latest_element_x = str(int(1+(int(len(inputname)/2)*10)-1)-0.007) + accent_02_multiplier = str(1+int(len(inputname)/2)) # Create File file = f"assets/svg/{inputname}.svg" with open(file, 'w', encoding='UTF-8') as outputfile: - outputfile.write(env.render_template('galaxy.svg', pad=pad, this={'title': rendered_title, 'name': inputname, "sizes": rendered_sizes, "orange_box_width": orange_box_width, "orange_position": orange_position})) + outputfile.write(env.render_template( + 'galaxy.svg', pad=pad, this={ + 'title': rendered_title, + 'name': inputname, + "sizes": rendered_sizes, + "orange_box_width": orange_box_width, + "orange_position": orange_position, + "accent03_x": latest_element_x, + "bg_orange_x": latest_element_x, + "accent_02_multiplier": accent_02_multiplier})) returnvalue = f"/svg/{inputname}.svg" return returnvalue