#28618: There should be a way to make Templates substitution to raise an 
exception
on error
-------------------------------------+-------------------------------------
     Reporter:  Facundo Batista      |                    Owner:  shreyas
         Type:  New feature          |                   Status:  assigned
    Component:  Template system      |                  Version:  1.11
     Severity:  Normal               |               Resolution:
     Keywords:  template error       |             Triage Stage:
  substitution                       |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by shreyas):

 It seems that there is a way to pass parameter `string_if_invalid` when
 initializing template engine which will be rendered in template if
 variable is not resolved from context. You can also pass `%s` in that
 string which will be interpolated with missing variable name.

 For Eg.

 {{{

 engine = Engine(debug=True, string_if_invalid="Variable not found %s")
 t = engine.from_string("{{articlecovfefe.section}}")
 c = Context({"article": {"section": "News"}})
 print(t.render(c))  # prints 'Variable not found articlecovfefe.section'
 != 'News'

 }}}


 Is it possible to leverage this in test cases for you.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/28618#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/072.d7d2d304a6a1e3b06012e1fda709b75a%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to