Last active
August 29, 2015 14:19
-
-
Save bterlson/2d3469e0f1bc2cf74d83 to your computer and use it in GitHub Desktop.
Chained tagged templates
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
function concat(head, template) { | |
"use strict"; | |
var head; | |
if(!template) { | |
template = head; | |
head = ''; | |
} | |
var fn = concat.bind(null, head + template[0]); | |
fn.toString = function() { | |
return head + template[0]; | |
}; | |
return fn | |
} | |
concat`1``2``abc`.toString(); // 12abc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment