From dd670025354bc5fc33a64b6100831e54640bc0ca Mon Sep 17 00:00:00 2001 From: Guillaume Yziquel Date: Thu, 24 Aug 2023 13:52:43 +0200 Subject: [PATCH] Keeping source tree in sync with 0.14.0 release on pypi. The github source tree was, previous to this commit, lagging behind the release on pypi. Github code was version 0.13.1 and Pypi was 0.14. The code in this commit is the one published on PyPi. --- chevron/metadata.py | 2 +- chevron/renderer.py | 25 ++++++++++--------------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/chevron/metadata.py b/chevron/metadata.py index 19912aa..449f1a3 100644 --- a/chevron/metadata.py +++ b/chevron/metadata.py @@ -1 +1 @@ -version = '0.13.1' +version = '0.14.0' diff --git a/chevron/renderer.py b/chevron/renderer.py index 65a00f6..f69d65f 100644 --- a/chevron/renderer.py +++ b/chevron/renderer.py @@ -48,7 +48,7 @@ def _html_escape(string): return string -def _get_key(key, scopes, warn, keep, def_ldel, def_rdel): +def _get_key(key, scopes, warn=False): """Get a key from the current scope""" # If the key is a dot @@ -94,9 +94,6 @@ def _get_key(key, scopes, warn, keep, def_ldel, def_rdel): if warn: sys.stderr.write("Could not find key '%s'%s" % (key, linesep)) - if keep: - return "%s %s %s" % (def_ldel, key, def_rdel) - return '' @@ -130,7 +127,7 @@ def _get_partial(name, partials_dict, partials_path, partials_ext): def render(template='', data={}, partials_path='.', partials_ext='mustache', partials_dict={}, padding='', def_ldel='{{', def_rdel='}}', - scopes=None, warn=False, keep=False): + scopes=None, warn=False): """Render a mustache template. Renders a mustache template with a data scope and partial capability. @@ -175,9 +172,7 @@ def render(template='', data={}, partials_path='.', partials_ext='mustache', scopes -- The list of scopes that get_key will look through - warn -- Issue a warning to stderr when a template substitution isn't found in the data - - keep -- Keep unreplaced tags when a template substitution isn't found in the data + warn -- Issue a warning to stderr when a template substitution isn't found in the data Returns: @@ -230,7 +225,7 @@ def render(template='', data={}, partials_path='.', partials_ext='mustache', # If we're a variable tag elif tag == 'variable': # Add the html escaped key to the output - thing = _get_key(key, scopes, warn=warn, keep=keep, def_ldel=def_ldel, def_rdel=def_rdel) + thing = _get_key(key, scopes, warn=warn) if thing is True and key == '.': # if we've coerced into a boolean by accident # (inverted tags do this) @@ -243,7 +238,7 @@ def render(template='', data={}, partials_path='.', partials_ext='mustache', # If we're a no html escape tag elif tag == 'no escape': # Just lookup the key and add it - thing = _get_key(key, scopes, warn=warn, keep=keep, def_ldel=def_ldel, def_rdel=def_rdel) + thing = _get_key(key, scopes, warn=warn) if not isinstance(thing, unicode_type): thing = unicode(str(thing), 'utf-8') output += thing @@ -251,7 +246,7 @@ def render(template='', data={}, partials_path='.', partials_ext='mustache', # If we're a section tag elif tag == 'section': # Get the sections scope - scope = _get_key(key, scopes, warn=warn, keep=keep, def_ldel=def_ldel, def_rdel=def_rdel) + scope = _get_key(key, scopes, warn=warn) # If the scope is a callable (as described in # https://mustache.github.io/mustache.5.html) @@ -292,7 +287,7 @@ def render(template='', data={}, partials_path='.', partials_ext='mustache', padding=padding, def_ldel=def_ldel, def_rdel=def_rdel, scopes=data and [data]+scopes or scopes, - warn=warn, keep=keep)) + warn=warn)) if python3: output += rend @@ -329,7 +324,7 @@ def render(template='', data={}, partials_path='.', partials_ext='mustache', partials_ext=partials_ext, partials_dict=partials_dict, def_ldel=def_ldel, def_rdel=def_rdel, - warn=warn, keep=keep) + warn=warn) if python3: output += rend @@ -343,7 +338,7 @@ def render(template='', data={}, partials_path='.', partials_ext='mustache', # If we're an inverted section elif tag == 'inverted section': # Add the flipped scope to the scopes - scope = _get_key(key, scopes, warn=warn, keep=keep, def_ldel=def_ldel, def_rdel=def_rdel) + scope = _get_key(key, scopes, warn=warn) scopes.insert(0, not scope) # If we're a partial @@ -364,7 +359,7 @@ def render(template='', data={}, partials_path='.', partials_ext='mustache', partials_dict=partials_dict, def_ldel=def_ldel, def_rdel=def_rdel, padding=part_padding, scopes=scopes, - warn=warn, keep=keep) + warn=warn) # If the partial was indented if left.isspace():