-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f2448e1
commit 018e116
Showing
5 changed files
with
51 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/** | ||
Simple micro templating. | ||
@param template - Text with placeholders for `data` properties. | ||
@param data - Data to interpolate into `template`. | ||
@example | ||
``` | ||
import pupa = require('pupa'); | ||
pupa('The mobile number of {name} is {phone.mobile}', { | ||
name: 'Sindre', | ||
phone: { | ||
mobile: '609 24 363' | ||
} | ||
}); | ||
//=> 'The mobile number of Sindre is 609 24 363' | ||
pupa('I like {0} and {1}', ['🦄', '🐮']); | ||
//=> 'I like 🦄 and 🐮' | ||
``` | ||
*/ | ||
declare function pupa( | ||
template: string, | ||
data: unknown[] | {[key: string]: unknown} | ||
): string; | ||
|
||
export = pupa; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import {expectType} from 'tsd'; | ||
import pupa = require('.'); | ||
|
||
expectType<string>( | ||
pupa('The mobile number of {name} is {phone.mobile}', { | ||
name: 'Sindre', | ||
phone: { | ||
mobile: '609 24 363' | ||
} | ||
}) | ||
); | ||
expectType<string>(pupa('I like {0} and {1}', ['🦄', '🐮'])); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters