Difference between revisions of "Jinja use custom block markers"
Jump to navigation
Jump to search
(Created page with "``` from jinja2 import Environment, FileSystemLoader # Create a Jinja environment with custom variable markers custom_env = Environment(loader=FileSystemLoader('your_template...") |
(No difference)
|
Latest revision as of 23:08, 6 March 2024
from jinja2 import Environment, FileSystemLoader # Create a Jinja environment with custom variable markers custom_env = Environment(loader=FileSystemLoader('your_template_directory'), block_start_string='[%', # Change this to your desired start marker block_end_string='%]') # Change this to your desired end marker # Load your template template = custom_env.get_template('your_template_file.html') # Render the template with your data rendered_output = template.render(your_variable='some_value') # Print or use the rendered output as needed print(rendered_output)