Closed agirton-twitter closed 9 years ago
Counterpart uses the sprintf module for interpolation. Sprintf allows you to use two percent signs (%%
) as escape sequence for a percent sign. So this works:
sprintf = require('sprintf').sprintf;
sprintf("foo %(name)s bar 27%% bam", { name: "baz" }); // => 'foo baz bar 27% bam'
Does that help?
That works for me. Thanks!
In our application 99% of the strings we are using are static. In these strings there are percent signs, if we set interpolation to false globally we don't have a problem. However if we set it to true even the strings without interpolation are trying to be parsed so
27%
throws an error from sprintf.Our fix is to have a few of the function calls that need interpolation to set the option to true. So we can still have it globally turned off.
Also fixed a test on line 329 in that the second assert should be interpolated if the local is set to true.
Love to know your thoughts on this.