Skip to content

Commit b8d9aa9

Browse files
committed
Remove template display name
1 parent 530ccd8 commit b8d9aa9

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/index.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export type Template<T extends object> = (data: T) => string;
77
/**
88
* Stringify a template into a function.
99
*/
10-
export function compile(value: string, displayName = "template") {
10+
export function compile(value: string) {
1111
let result = QUOTE_CHAR;
1212
for (let i = 0; i < value.length; i++) {
1313
const char = value[i];
@@ -50,16 +50,13 @@ export function compile(value: string, displayName = "template") {
5050
}
5151
result += QUOTE_CHAR;
5252

53-
return `function ${displayName}(${INPUT_VAR_NAME}) { return ${result}; }`;
53+
return `function (${INPUT_VAR_NAME}) { return ${result}; }`;
5454
}
5555

5656
/**
5757
* Fast and simple string templates.
5858
*/
59-
export function template<T extends object = object>(
60-
value: string,
61-
displayName?: string
62-
) {
63-
const body = compile(value, displayName);
59+
export function template<T extends object = object>(value: string) {
60+
const body = compile(value);
6461
return new Function(`return (${body});`)() as Template<T>;
6562
}

0 commit comments

Comments
 (0)