Last active
October 4, 2023 01:12
-
-
Save protomorph/06e0230691ad2a2ffed908cece6fade4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| import tagged from 'tagged.js' | |
| const css = tagged(function (str) { | |
| const css = new CSSStyleSheet() | |
| return css.replace(str.trim()) | |
| }) | |
| export default css |
This file contains hidden or 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
| import tagged from 'tagged.js' | |
| const html = tagged(function (str) { | |
| const fragment = document.createRange() | |
| return fragment.createContextualFragment(str.trim()) | |
| }) | |
| export default html |
This file contains hidden or 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
| // https://github.com/ryanmorr/tagged | |
| export default function tagged (callback, mutator = val => val) { | |
| return (strings, ...values) => callback( | |
| strings.raw.reduce((acc, str, i) => acc + (mutator(values[i - 1])) + str) | |
| ) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment