mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-25 20:03:12 +03:00
Added new tests & missing return type to tpl
- Ensuring that various strings from en.json will work - Added missing return type
This commit is contained in:
parent
b06e2a4577
commit
224c6996f1
@ -11,7 +11,7 @@ const interpolate = /(?<!{){([^{]+?)}/g;
|
||||
*
|
||||
* @param {String} string - string with optional {data properties}
|
||||
* @param {Object} [data] - optional data to interpolate
|
||||
* @returns
|
||||
* @returns {string} the interpolated string
|
||||
*/
|
||||
module.exports = (string, data) => {
|
||||
if (!data) {
|
||||
|
@ -20,7 +20,7 @@ describe('tpl', function () {
|
||||
result.should.eql('Go visit https://example.com');
|
||||
});
|
||||
|
||||
it('Can handle mixing with handlebars-related messages', function () {
|
||||
it('Can mix interpolation handlebars in the same message', function () {
|
||||
const string = '{{#get}} helper took {totalMs}ms to complete';
|
||||
const data = {
|
||||
totalMs: '500'
|
||||
@ -30,6 +30,18 @@ describe('tpl', function () {
|
||||
result.should.eql('{{#get}} helper took 500ms to complete');
|
||||
});
|
||||
|
||||
it('Can mix interpolation with handlebars-block helpers without escaping', function () {
|
||||
const string = '{{#{helperName}}} helper took {totalMs}ms to complete';
|
||||
|
||||
const data = {
|
||||
helperName: 'get',
|
||||
totalMs: '500'
|
||||
};
|
||||
|
||||
let result = tpl(string, data);
|
||||
result.should.eql('{{#get}} helper took 500ms to complete');
|
||||
});
|
||||
|
||||
it('Can handle escaped left braces', function () {
|
||||
const string = 'The \\{\\{{helperName}}} helper is not available.';
|
||||
const data = {
|
||||
|
Loading…
Reference in New Issue
Block a user