Skip to content

Commit 4eb1c3e

Browse files
committed
Renames interpolation method
1 parent 95e0a6c commit 4eb1c3e

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

src/git/formatters/commit.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ export class CommitFormatter {
134134
options = dateFormatOrOptions;
135135
}
136136

137-
return Strings.interpolateLazy(template, new CommitFormatter(commit, options));
137+
return Strings.interpolate(template, new CommitFormatter(commit, options));
138138
}
139139

140140
static toHoverAnnotation(commit: GitCommit, dateFormat: string = 'MMMM Do, YYYY h:MMa'): string | string[] {

src/system/string.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
'use strict';
2-
import { Objects } from './object';
32
const _escapeRegExp = require('lodash.escaperegexp');
43

54
export namespace Strings {
@@ -37,13 +36,11 @@ export namespace Strings {
3736
return tokens;
3837
}
3938

40-
export function interpolate(template: string, tokens: { [key: string]: any }): string {
41-
return new Function(...Object.keys(tokens), `return \`${template}\`;`)(...Objects.values(tokens));
42-
}
39+
export function interpolate(template: string, context: object): string {
40+
if (!template) return template;
4341

44-
export function interpolateLazy(template: string, context: object): string {
45-
template = template.replace(TokenSanitizeRegex, '$${c.$1}');
46-
return new Function('c', `return \`${template}\`;`)(context);
42+
template = template.replace(TokenSanitizeRegex, '$${this.$1}');
43+
return new Function(`return \`${template}\`;`).call(context);
4744
}
4845

4946
export function padLeft(s: string, padTo: number, padding: string = '\u00a0') {

0 commit comments

Comments
 (0)