mercredi 6 mai 2015

Is there any way to turn a 'normal' string into ES6 Template string? [duplicate]

This question already has an answer here:

Is there any way to turn a 'normal' string into ES6 Template string?
I mean to make it using ES6 capabilities without tricky regexps or something.

I need it cause I'm getting string from db and want to use it as a template to produce output. Like this:

var message = db.getMyTemplate();//message holds `Yo, ${name}!`
var valueToPutIntoTemplate = 'Brendan';
console.log(message); 

the output is Yo, ${name}!. Is there any way to get "Yo, Brendan!" here?

Best regards, Eugene.

Aucun commentaire :

Enregistrer un commentaire