Skip to content

Instantly share code, notes, and snippets.

@shunjikonishi
Last active December 16, 2015 20:39
Show Gist options
  • Save shunjikonishi/5493788 to your computer and use it in GitHub Desktop.
Save shunjikonishi/5493788 to your computer and use it in GitHub Desktop.
Template of messages.js (Playframework 2 - scala)
@(map: Map[String, String])
if (typeof(flect) == "undefined") flect = {};
if (typeof(flect.app) == "undefined") flect.app = {};
if (typeof(flect.app.XXXX) == "undefined") flect.app.XXXX = {};
flect.app.XXXX.MSG = {@map.map{ case(key, value) =>
"@key" : "@value",}
"format" : function(fmt) {
for (i = 1; i < arguments.length; i++) {
var reg = new RegExp("\\{" + (i - 1) + "\\}", "g")
fmt = fmt.replace(reg,arguments[i]);
}
return fmt;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment