question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to override Jinja2 block_start_string

See original GitHub issue

Hi, I’m trying to override certain Jinja2 environment defaults like block_start_string:

import jinja2

jinja_env = jinja2.Environment(
    block_start_string = '<%',
    block_end_string = '%>',
    variable_start_string = '<<',
    variable_end_string = '>>'
)

I’m loading that extension file with yasha -e my_extension.py however it doesn’t take effect as I don’t know how to activate that jinja_env I’m creating.

Thanks for maintaining this project!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

0reactions
elgalucommented, May 1, 2018

Works!! Thanks

Read more comments on GitHub >

github_iconTop Results From Across the Web

Change the block start string in Django templates
Django does not currently support changing the block start or end strings, however Django does support using Jinja2 as a template backend.
Read more >
template module does not interprets the custom jinja2 ... - GitHub
Summary below template adds custom jinja2 environment settings #jinja2:variable_start_string:'[%' , variable_end_string:'%]' ...
Read more >
Template - jancy
Since Ansible version 0.9, templates are loaded with C(trim_blocks=True). Also, you can override jinja2 settings by adding a special header to template file....
Read more >
jigo package - github.com/jmoiron/jigo - Go Packages
Jigo is a Jinja2-like template language for Go. It is in pre-alpha stages and not yet ready for use much less production. Any...
Read more >
cannot import name 'soft_unicode' from 'markupsafe' jupyter ...
File "C:\Users\NXHSE\anaconda3\lib\site-packages\jinja2\filters.py", line 13, ... import BLOCKSTARTSTRING 27 from .defaults import COMMENTENDSTRING.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found