Last active
January 25, 2018 16:22
-
-
Save bitsmanent/6ff5d8e5a89b08c2a8c2 to your computer and use it in GitHub Desktop.
Build a view from a template and a data set. Replace %{key} with the corresponding value.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function mkview(tpl, d) { | |
| var ret = tpl, re, k; | |
| for(k in d) { | |
| re = new RegExp("%{"+k+"}", "g"); | |
| ret = ret.replace(re , d[k]); | |
| } | |
| return ret; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment