-
-
Notifications
You must be signed in to change notification settings - Fork 683
gherkin: an alternative syntax to <...> for interpolating values into a Scenario Outline #1004
Description
Summary
Currently there is two constructs to encapsulate a DocString namely """ and ```. I'm wondering could such an option be added for interpolating values into a Scenario Outline|Template. Preferably any alternative syntax to <...> could be configurable too.
Current Behavior
The construct <...> works well in most cases however imo it introduces a usability issue when the syntax is used in conjunction with a DocString that has XML|HTML content. For example
Scenario Templates: The parser accepts formatted text
Given some xml text
"""<xml>
<xml><xmlHeader>Hello world!<xmlFooter></xml>
"""
Given some html text
"""<html>
<html><htmlHeader>Hello world!<htmlFooter></html>
"""
Scenarios:
| xmlHeader | xmlFooter | htmlHeader | htmlFooter |
| <soap:Header> | </soap:Header> | <head> | </head> |
Possible Solution
The suggestion would be that we can have another variable syntax for example {{xmlHeader}} that has the same functionality as <xmlHeader>, etc. I think it reads much better when you use those formats. See below:
Given some html text
"""<html>
<html>{{htmlHeader}}Hello world!{{htmlFooter}}</html>
"""
Note reason for {{...}} is that it's used in testing tools like postman plus template engine libraries for example Django that has implementations in Python, Java, JavaScript and C# AFAIK. Some other string interpolation syntaxes potentially to consider:
${foo} - EcmaScript, Perl, PHP, Bash, Dart, Groovy
$foo - Bash, Dart
#{foo} - Ruby, CoffeeScript
{foo} - JSX, Python 3.6
Context & Motivation
Imo it fixes a usability issue that comes about from using variable substitution with Scenario Outline|template in conjunction with a DocString when the content of the DocString is HTML|XML.