freeplay 0.3.6__tar.gz → 0.3.7__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: freeplay
3
- Version: 0.3.6
3
+ Version: 0.3.7
4
4
  Summary:
5
5
  License: MIT
6
6
  Author: FreePlay Engineering
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "freeplay"
3
- version = "0.3.6"
3
+ version = "0.3.7"
4
4
  description = ""
5
5
  authors = ["FreePlay Engineering <engineering@freeplay.ai>"]
6
6
  license = "MIT"
@@ -1,3 +1,4 @@
1
+ import json
1
2
  from typing import Dict, Union, Optional, Any
2
3
  import importlib.metadata
3
4
  import platform
@@ -20,6 +21,18 @@ def all_valid(obj: Any) -> bool:
20
21
  return False
21
22
 
22
23
 
24
+ class StandardPystache(pystache.Renderer): # type: ignore
25
+
26
+ def __init__(self) -> None:
27
+ super().__init__(escape=lambda s: s)
28
+
29
+ def str_coerce(self, val: Any) -> str:
30
+ if isinstance(val, dict) or isinstance(val, list):
31
+ # We hide spacing after punctuation so that the templating is the same across all SDKs.
32
+ return json.dumps(val, separators=(',', ':'))
33
+ return str(val)
34
+
35
+
23
36
  def bind_template_variables(template: str, variables: InputVariables) -> str:
24
37
  if not all_valid(variables):
25
38
  raise FreeplayError(
@@ -28,7 +41,7 @@ def bind_template_variables(template: str, variables: InputVariables) -> str:
28
41
  )
29
42
 
30
43
  # When rendering mustache, do not escape HTML special characters.
31
- rendered: str = pystache.Renderer(escape=lambda s: s).render(template, variables)
44
+ rendered: str = StandardPystache().render(template, variables)
32
45
  return rendered
33
46
 
34
47
 
File without changes
File without changes
File without changes
File without changes