How To Refactor Ruby's #{} Method In Javascript Which I Write
When I'm writing Javascript code, I feel miss Ruby's #{} method.So I implement it in JS. But this code is not clean and beautiful. I want to make this method safe, But I can't do
Solution 1:
The closest thing to what you want would be a templating system, such as mustache. It lets you do things like:
var person = {
name: "nobi",
age: 23
};
var output = Mustache.render("I'm {{name}} and I am {{age}} years old.", person);
Solution 2:
Or use coffeescript.
http://coffeescript.org/#strings
Also #{}
isn't a method in Ruby, it's called "string interpolation".
http://en.wikibooks.org/wiki/Ruby_Programming/Syntax/Literals#Interpolation
Post a Comment for "How To Refactor Ruby's #{} Method In Javascript Which I Write"