Created
March 5, 2015 13:06
-
-
Save eiszfuchs/772011ef211e40f18e53 to your computer and use it in GitHub Desktop.
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 (value, config) { | |
| var matchbox = /{([^a-z]?)([a-z_]+)([^a-z|]?)(\|[^}]+)?}/g; | |
| var translator = function (match, prefix, value, suffix, defaultValue) { | |
| if (config.hasOwnProperty(value)) { | |
| return prefix + config[value] + suffix; | |
| } | |
| if (defaultValue) { | |
| return defaultValue.replace('|', ''); | |
| } | |
| return ''; | |
| }; | |
| return value.replace(matchbox, translator); | |
| }('server { listen {port|80}; server_name {sub_domain.}{domain}; }', { | |
| // port: 8080, | |
| sub_domain: 'www', | |
| domain: 'example.com' | |
| })); | |
| // "server { listen 80; server_name www.example.com; }" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment