Skip to content

Instantly share code, notes, and snippets.

@Jimmydalecleveland
Created August 22, 2019 00:05
Show Gist options
  • Save Jimmydalecleveland/06316aca2301f52ee6985773e4b0af6e to your computer and use it in GitHub Desktop.
Save Jimmydalecleveland/06316aca2301f52ee6985773e4b0af6e to your computer and use it in GitHub Desktop.
function taggedTemplate(stringArray, variable) {
console.log(stringArray)
// [ 'The string will be split here: ', ' Then it resumes here.' ]
console.log(variable)
// I am the great divider!
return `${stringArray[0]}${variable}${stringArray[1]}`
}
const stringVar = "I am the great divider!"
const customSentence = taggedTemplate`The string will be split here: ${stringVar} Then it resumes here.`
console.log(customSentence)
// The string will be split here: I am the great divider! Then it resumes here.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment