-
-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Export template function #8
Conversation
This facilitates wrapping template behavior in other functions, and not needing to reference the tag function in many places.
I'm indifferent to exposing this. Deferring to @Qix-. However, this will need tests, docs, and TS types for it to be mergable. |
Exposing it is fine, but agreed, needs tests, types and docs. Docs need to mention that all input needs to be properly escaped - a lot of the "safety" comes from using tagged literals. |
Additionally add typescript as a dev dependency
@Qix- @sindresorhus I've updated the branch to include tests, types, and docs. I was a little unsure about what to do but welcome any feedback. I also added typescript as a dev dependency because it seemed that |
Thank you :) Published as |
``` | ||
import { template } from 'chalk-template'; | ||
|
||
log(template('Today is {red hot}') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Multiple typos
|
||
@example | ||
``` | ||
import { template } from 'chalk-template'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does not follow the existing code style.
@@ -49,6 +49,7 @@ | |||
"ava": "^3.15.0", | |||
"cross-env": "^7.0.3", | |||
"tsd": "^0.18.0", | |||
"typescript": "^4.6.2", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't make unrelated changes.
@@ -58,6 +58,16 @@ Note that function styles (`rgb()`, etc.) may not contain spaces between paramet | |||
|
|||
All interpolated values (`` chalkTemplate`${foo}` ``) are converted to strings via the `.toString()` method. All curly braces (`{` and `}`) in interpolated value strings are escaped. | |||
|
|||
## Template function | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Readme is not in sync with index.d.ts
This was not done. |
I cleaned this up in bf830d7. |
Whoops sorry @sindresorhus, missed the mark on this one. Thanks for cleaning it up. |
* Export template function This facilitates wrapping template behavior in other functions, and not needing to reference the tag function in many places. * Add tests and types Additionally add typescript as a dev dependency * Update README
This facilitates wrapping template behavior in other functions, and not needing to reference the tag function in many places.
In my case, I've created custom
Console
class that can be configured to have different prefixes, I'd like to be able to instantiate the class with a color template without needing to importchalk
orchalk-template
in multiple places