summaryrefslogtreecommitdiff
path: root/django/template/base.py
AgeCommit message (Collapse)Author
2022-05-20Fixed #33653 -- Fixed template crash when calling methods for built-in types ↵cheng
without required arguments. Regression in 09341856ed9008875c1cc883dc0c287670131458.
2022-02-16Removed unused Node.__iter__().Keryn Knight
2022-02-07Refs #33476 -- Reformatted code with Black.django-bot
2022-02-03Refs #33476 -- Refactored problematic code before reformatting by Black.Mariusz Felisiak
In these cases Black produces unexpected results, e.g. def make_random_password( self, length=10, allowed_chars='abcdefghjkmnpqrstuvwxyz' 'ABCDEFGHJKLMNPQRSTUVWXYZ' '23456789', ): or cursor.execute(""" SELECT ... """, [table name], )
2022-02-02Fixed #33474 -- Added __slots__ to Variable and FilterExpression.Keryn Knight
2022-01-07Avoided isinstance(…, Variable) calls in FilterExpression.resolve().Keryn Knight
By determining the variable type within __init__() instead of resolve() we can skip an isinstance() check at template runtime. Templates are executed in production more often than the parse trees themselves, assuming the cached Loader is used.
2021-08-25Refs #32919 -- Simplified Lexer.create_token() by reorganizing blocks.Chris Jerdonek
2021-08-25Refs #32919 -- Added assertion for token start in Lexer.create_token().Chris Jerdonek
This adds an assertion in the code path where the method would otherwise return None, which isn't allowed.
2021-08-09Fixed #33002 -- Made DebugLexer.tokenize() more closely parallel ↵Chris Jerdonek
Lexer.tokenize().
2021-08-09Refs #33002 -- Renamed variable from bit to token_string in Lexer.tokenize().Chris Jerdonek
2021-08-09Refs #33002 -- Optimized Lexer.tokenize() by skipping computing lineno when ↵Chris Jerdonek
not needed.
2021-08-09Fixed #32990 -- Simplified and optimized tag regex.Greg Twohig
Thanks Chris Jerdonek for the review.
2021-08-05Refs #32986 -- Moved TRANSLATOR_COMMENT_MARK to ↵Chris Jerdonek
django.utils.translation.template.
2021-08-05Fixed #32986 -- Removed unneeded str.find() call in Lexer.create_token().Chris Jerdonek
Unnecessary since 47ddd6a4082d55d8856b7e6beac553485dd627f7.
2021-08-02Fixed #32919 -- Optimized lexing & parsing of templates.Keryn Knight
This optimizes: - Lexer.create_token() by avoiding startswith() calls, - Parser.parse() by re-using the token type enum's value, - Parser.extend_nodelist() by removing unnecessary isinstance() check, - some Node subclasses by removing the implicit "nodelist" from "child_nodelists", - Variable.__init__() by avoiding startswith() calls.
2021-07-02Fixed #28935 -- Fixed display of errors in extended blocks.cammil
Get the template that caused the exception and get the exception info from that template, using the node that caused the exception.
2021-06-11Fixed #32824 -- Improved performance of NodeList.render().Keryn Knight
This avoids the following: - checking that each item in the nodelist is a subclass of Node, - calling str() on the render_annotated() output, because it's documented that Node.render() must return a string, - calling mark_safe() on the output, when the value to be wrapped is definitively known to be a string because the result of ''.join() is always of that type, - using an intermediate list to store each individual string.
2021-06-07Fixed #32814 -- Improved performance of TextNode.Keryn Knight
This avoids calling render() and handling exceptions, which is not necessary for text nodes.
2021-03-17Refs #24121 -- Added __repr__() to Origin and Template.Tiago Honorato
2021-02-26Refs #24121 -- Added __repr__() to FilterExpression, Lexer, Parser, and Token.David Smith
2020-05-11Refs #30116 -- Simplified regex match group access with Match.__getitem__().Jon Dufresne
The method has been available since Python 3.6. The shorter syntax is also marginally faster.
2019-12-10Used Signature API instead of deprecated inspect.getcallargs().Baptiste Mispelon
inspect.getcallargs() was deprecated in Python 3.5 and the Signature API (PEP 362) has better support for decorated functions (by default, it follows the __wrapped__ attribute set by functools.wraps for example).
2019-12-10Used full module import for inspect in template/base.py.Baptiste Mispelon
2019-10-29Fixed #30899 -- Lazily compiled import time regular expressions.Hasan Ramezani
2019-10-09Improved performance of django.template.base.Parser.Alex Gaynor
pop(0), which is used to fetch each token, is O(n) in the length of the list. By reversing the list and operating off the end, we can perform next_token(), prepend_token(), and delete_first_token() in constant time.
2019-10-02Fixed some typos in comments and docs.Min ho Kim
Thanks to Mads Jenson for review.
2019-09-24Removed some outdated backwards compatibility imports and misleading comments.Mads Jensen
EmptyResultSet moved in 46509cf13dbf049f75077981c29ef2c60b5a96ab. FieldDoesNotExist moved in 8958170755b37ce346ae5257c1000bd936faa3b0. BoundField and pretty_name moved in 8550161e531a603d57723850fb09c4c9b7ca60b9. EMPTY_VALUES moved in 471596fc1afcb9c6258d317c619eaf5fd394e797. BaseRunserverCommand moved in 5c53e30607014163872e89c221b206992a9acfef.
2019-05-07Removed unnecessary line in DebugLexer.tokenize().sanchjat
2018-08-01Fixed typos in comments and docs.luz.paz
2018-07-31Fixed #29617 -- Fixed Template crash if template_string is lazy.Dražen Odobašić
Regression in 3a148f958dddd97c1379081118c30fbede6b6bc4.
2018-05-25Fixed #29400 -- Fixed crash in custom template filters that use decorated ↵Ryan Rubin
functions. Regression in 620e9dd31a2146d70de740f96a8cb9a6db054fc7.
2018-05-10Replaced TOKEN_* constants by TokenType enums.Claude Paroz
Thanks Tim Graham for the review.
2018-03-24Removed unnecessary variable in Lexer.create_token().Mads Jensen
2017-10-21Fixed #28730 -- Fixed loss of precision for large integer literals in templatesClaude Paroz
Thanks Fraser Nevett for the report and Tim Graham for patch edits.
2017-09-28Simplified various __eq__() methods.Mads Jensen
2017-08-23Removed unneeded iter() calls.Sergey Fedoseev
A few of these were unnecessarily added in 2b281cc35ed9d997614ca3c416928d7fabfef1ad.
2017-04-27Replaced django.utils.inspect.getargspec() with inspect.getfullargspec().Alexander Allakhverdiyev
2017-02-23Refs #23919 -- Used yield from.Vytis Banaitis
2017-02-17Refs #27656 -- Updated django.template/tag docstring verbs according to PEP 257.Anton Samarchyan
2017-02-07Refs #27795 -- Removed force_text from the template layerClaude Paroz
Thanks Tim Graham for the review.
2017-02-07Converted usage of ugettext* functions to their gettext* aliasesClaude Paroz
Thanks Tim Graham for the review.
2017-02-06Fixed #27783 -- Switched VariableDoesNotExist.__str__() to repr() context.Ryan O’Hara
Using __str__() and then repr'ing the result looks strange and can lead to recursive rendering of forms.
2017-01-26Refs #23919, #27778 -- Removed obsolete mentions of unicode.Vytis Banaitis
2017-01-25Removed unused variables that are overwritten.Mads Jensen
2017-01-21Refs #23919 -- Removed re.U and re.UNICODE (default on Python 3).Mariusz Felisiak
2017-01-20Refs #23919 -- Removed unneeded force_str callsClaude Paroz
2017-01-19Refs #23919 -- Stopped inheriting from object to define new style classes.Simon Charette
2017-01-18Refs #23919 -- Removed obsolete __ne__() methods.Aymeric Augustin
__ne__() defaults to the opposite of __eq__() on Python 3 when it doesn't return NotImplemented.
2017-01-18Refs #23919 -- Removed six.<various>_types usageClaude Paroz
Thanks Tim Graham and Simon Charette for the reviews.
2017-01-18Refs #23919 -- Removed python_2_unicode_compatible decorator usageClaude Paroz