5 ms·
I was wondering how they pulled of the R`` expressions because I didn't realize that JS added "tagged templates" like this [1]. So if nothing I learned somethin
by wybiral 8y ago
I was wondering how they pulled of the R`` expressions because I didn't realize that JS added "tagged templates" like this [1]. So if nothing I learned something new by reading this tiny bit of code.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#Tagged_templates https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
- antonvs 8y agoIt's ironic that this is being used in a "brutalist" framework, because tagged templates seem really poorly designed and overcomplex - using a monolithic function to process an entire template, instead of compositionally building it from components that can be independent (but don't have to be.) The example in your link could easily be implemented by a much simpler templating feature in which you just call functions to transform the parameters, e.g.: "That ${ person } is a ${ characterize(age) }" If you want shared state between your template expansions, you can create an object that exposes the required transformations, and it'll still be better designed than that example.