diff --git a/src/utils/PhutilCowsay.php b/src/utils/PhutilCowsay.php --- a/src/utils/PhutilCowsay.php +++ b/src/utils/PhutilCowsay.php @@ -71,14 +71,19 @@ $template); } - $template = preg_replace_callback( + $token_patterns = array( '/\\$([a-z]+)/', - array($this, 'replaceTemplateVariable'), - $template); - if ($template === false) { - throw new Exception( - pht( - 'Failed to replace template variables while rendering cow!')); + '/\\${([a-z]+)}/', + ); + foreach ($token_patterns as $token_pattern) { + $template = preg_replace_callback( + $token_pattern, + array($this, 'replaceTemplateVariable'), + $template); + if ($template === false) { + throw new Exception( + pht('Failed to replace template variables while rendering cow!')); + } } $lines = $this->text; diff --git a/src/utils/__tests__/cowsay/sheep.expect b/src/utils/__tests__/cowsay/sheep.expect new file mode 100644 --- /dev/null +++ b/src/utils/__tests__/cowsay/sheep.expect @@ -0,0 +1,11 @@ + __________________ +< How are my eyes? > + ------------------ + \ + \ + __ + UooU\.'@@@@@@`. + \__/(@@@@@@@@@@) + (@@@@@@@@) + `YY~~~~YY' + || || diff --git a/src/utils/__tests__/cowsay/sheep.test b/src/utils/__tests__/cowsay/sheep.test new file mode 100644 --- /dev/null +++ b/src/utils/__tests__/cowsay/sheep.test @@ -0,0 +1,13 @@ + $thoughts + $thoughts + __ + U${eyes}U\.'@@@@@@`. + \__/(@@@@@@@@@@) + (@@@@@@@@) + `YY~~~~YY' + || || +~~~~~~~~~~ +{ + "text": "How are my eyes?", + "eyes": "oo" +}