Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(398)

Unified Diff: telemetry/telemetry/util/js_template.py

Issue 2692763002: Revert of [Telemetry] Switch clients to new JavaScript API (batch 5) (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « telemetry/telemetry/page/page_test_unittest.py ('k') | telemetry/telemetry/util/js_template_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: telemetry/telemetry/util/js_template.py
diff --git a/telemetry/telemetry/util/js_template.py b/telemetry/telemetry/util/js_template.py
index 8e23f5c4c91b681487fbbad01d4f331dff3479d3..c167ebc3afa1922baed36966e49d940cd65a4f4b 100644
--- a/telemetry/telemetry/util/js_template.py
+++ b/telemetry/telemetry/util/js_template.py
@@ -7,7 +7,7 @@
RE_REPLACEMENT_FIELD = re.compile(r'{{(?P<field_spec>[^}]*)}}')
-RE_FIELD_IDENTIFIER = re.compile(r'(?P<modifier>[@*])?(?P<name>\w+)$')
+RE_FIELD_IDENTIFIER = re.compile(r'(?P<modifier>@)?(?P<name>\w+)$')
def RenderValue(value):
@@ -19,24 +19,19 @@
"""Helper method to interpolate Python values into JavaScript snippets.
Placeholders in the template, field names enclosed in double curly braces,
- are replaced with the value of the corresponding named argument.
-
- Prefixing a field name with '*' causes the value, expected to be a
- sequence of individual values, to be all interpolated and separated by
- commas.
-
- Prefixing a field name with '@' causes the value to be inserted literally.
+ are replaced with the value of the corresponding named argument. Prefixing
+ a field name with '@' causes the value to be inserted literally.
For example:
js_template.Render(
- 'var {{ @var_name }} = f({{ x }}, {{ *args }});',
- var_name='foo', x=42, args=('hello', 'there'))
+ 'var {{ @var_name }} = f({{ x }}, {{ y }});',
+ var_name='foo', x=42, y='hello')
Returns:
- 'var foo = f(42, "hello", "there");'
+ 'var foo = f(42, "hello");'
Args:
template: A string with a JavaScript template, tagged with {{ fields }}
@@ -57,8 +52,6 @@
if not isinstance(value, str):
raise ValueError('Literal value for %s must be a string' % field_spec)
return value
- elif field.group('modifier') == '*':
- return ', '.join(RenderValue(v) for v in value)
else:
return RenderValue(value)
« no previous file with comments | « telemetry/telemetry/page/page_test_unittest.py ('k') | telemetry/telemetry/util/js_template_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698