Converted Ruby template in Javascript