diff -r dc171b1d8261 -r 362cd1b6f81a eric6/DebugClients/Python/coverage/templite.py --- a/eric6/DebugClients/Python/coverage/templite.py Wed Feb 19 19:38:36 2020 +0100 +++ b/eric6/DebugClients/Python/coverage/templite.py Sat Feb 22 14:27:42 2020 +0100 @@ -1,5 +1,5 @@ # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 -# For details: https://bitbucket.org/ned/coveragepy/src/default/NOTICE.txt +# For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt """A simple Python template renderer, for a nano-subset of Django syntax. @@ -90,7 +90,10 @@ {# This will be ignored #} - Any of these constructs can have a hypen at the end (`-}}`, `-%}`, `-#}`), + Lines between `{% joined %}` and `{% endjoined %}` will have lines stripped + and joined. Be careful, this could join words together! + + Any of these constructs can have a hyphen at the end (`-}}`, `-%}`, `-#}`), which will collapse the whitespace following the tag. Construct a Templite with the template text, then use `render` against a @@ -154,7 +157,7 @@ # Split the text to form a list of tokens. tokens = re.split(r"(?s)({{.*?}}|{%.*?%}|{#.*?#})", text) - squash = False + squash = in_joined = False for token in tokens: if token.startswith('{'): @@ -196,6 +199,9 @@ ) ) code.indent() + elif words[0] == 'joined': + ops_stack.append('joined') + in_joined = True elif words[0].startswith('end'): # Endsomething. Pop the ops stack. if len(words) != 1: @@ -206,12 +212,17 @@ start_what = ops_stack.pop() if start_what != end_what: self._syntax_error("Mismatched end tag", end_what) - code.dedent() + if end_what == 'joined': + in_joined = False + else: + code.dedent() else: self._syntax_error("Don't understand tag", words[0]) else: # Literal content. If it isn't empty, output it. - if squash: + if in_joined: + token = re.sub(r"\s*\n\s*", "", token.strip()) + elif squash: token = token.lstrip() if token: buffered.append(repr(token))