mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-02-17 02:51:47 -05:00
Renames interpolation method
This commit is contained in:
@@ -134,7 +134,7 @@ export class CommitFormatter {
|
|||||||
options = dateFormatOrOptions;
|
options = dateFormatOrOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Strings.interpolateLazy(template, new CommitFormatter(commit, options));
|
return Strings.interpolate(template, new CommitFormatter(commit, options));
|
||||||
}
|
}
|
||||||
|
|
||||||
static toHoverAnnotation(commit: GitCommit, dateFormat: string = 'MMMM Do, YYYY h:MMa'): string | string[] {
|
static toHoverAnnotation(commit: GitCommit, dateFormat: string = 'MMMM Do, YYYY h:MMa'): string | string[] {
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
import { Objects } from './object';
|
|
||||||
const _escapeRegExp = require('lodash.escaperegexp');
|
const _escapeRegExp = require('lodash.escaperegexp');
|
||||||
|
|
||||||
export namespace Strings {
|
export namespace Strings {
|
||||||
@@ -37,13 +36,11 @@ export namespace Strings {
|
|||||||
return tokens;
|
return tokens;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function interpolate(template: string, tokens: { [key: string]: any }): string {
|
export function interpolate(template: string, context: object): string {
|
||||||
return new Function(...Object.keys(tokens), `return \`${template}\`;`)(...Objects.values(tokens));
|
if (!template) return template;
|
||||||
}
|
|
||||||
|
|
||||||
export function interpolateLazy(template: string, context: object): string {
|
template = template.replace(TokenSanitizeRegex, '$${this.$1}');
|
||||||
template = template.replace(TokenSanitizeRegex, '$${c.$1}');
|
return new Function(`return \`${template}\`;`).call(context);
|
||||||
return new Function('c', `return \`${template}\`;`)(context);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function padLeft(s: string, padTo: number, padding: string = '\u00a0') {
|
export function padLeft(s: string, padTo: number, padding: string = '\u00a0') {
|
||||||
|
|||||||
Reference in New Issue
Block a user