mirror of
https://github.com/Polymer/polymer.git
synced 2025-02-25 18:55:30 -06:00
add 'macroize' to utils
This commit is contained in:
@@ -440,12 +440,24 @@ license that can be found in the LICENSE file.
|
||||
}
|
||||
};
|
||||
|
||||
// string interpolation
|
||||
var macroize = function(inText, inMap, inPattern) {
|
||||
var result = inText, pattern = inPattern || macroize.pattern;
|
||||
var fn = function(macro, name) {
|
||||
var v = inMap[name];
|
||||
return (v === undefined || v === null) ? macro : v;
|
||||
};
|
||||
result = result.replace(pattern, fn);
|
||||
return result;
|
||||
};
|
||||
// Matches macros of the form {{name}}.
|
||||
macroize.pattern = /\{{([^{}]*)\}}/g;
|
||||
|
||||
// collect utils
|
||||
|
||||
var utils = {
|
||||
job: job,
|
||||
macroize: macroize,
|
||||
findDistributedTarget: findDistributedTarget
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user