Skip to content Skip to sidebar Skip to footer

How Can I Call A Template Literal Tag Function On A Regular String?

If I have a template literal tag function foo, which let's me do: const fooTaggedText = foo`some text`; is it possible for me to somehow call that tag on a regular string? For in

Solution 1:

I'm not sure if I got it, but wouldn't this work?

consttaggedText = str => foo`${str}`;

So you'd use it like:

taggedText('my string')

// foo`my string`

Please give some rep if it helps :)

Post a Comment for "How Can I Call A Template Literal Tag Function On A Regular String?"