Parse a value and convert it to a template string.
If the template is a function, execute it and pass the `bem()` function,
and the current namespace as arguments.

@param {String|Function} template
@returns {String}
344629
function(template) {
        if (typeof template === 'function') {
            template = template.call(null, Toolkit.bem, Toolkit.namespace);
        }

        return template + '';
    }
90559
function template(strings, ...keys) {
  return function(...values) {
    let dict = values[values.length - 1] || {};
    let result = [strings[0]];
    keys.forEach(function(key, i) {
      let value = isInteger(key) ? values[key] : dict[key];
      result.push(value, strings[i + 1]);
    });
    return result.join('');
  };
}
264408
function(templateName, options) {
        var template = this.templates[templateName];
        if (!template) {
            throw new Error('Unknown template: ' + templateName);
        }

        if (typeof template === 'function') {
            var templateResult = template(options);
            return typeof templateResult === 'string' ? templateResult.trim() : templateResult;
        } else if (template.render) {
            return template.render(options).trim();
        } else {
            return template.toString().trim();
        }
    }
1038077
public String template(String template, Map<String,Object> data)
            throws ScriptException,ScriptLimitException,SyntaxException{
        return template(null,template,data);
    }
558132
function expand(template, data) {
    if (template.indexOf("{{") >= 0) {
        let ast = myna.parsers.mustache(template);
        let lines = expandAst(ast, data);
        return lines.join("");
    } 
    else {
        return template;
    }
}
1347694
function compile(format) {
  /* istanbul ignore if */
  if (typeof format !== 'string') {
    throw new TypeError('argument format must be a string');
  }
  const fmt = format.replace(/"/g, '\\"');
  /* eslint prefer-template:0 */
  const js = '  return "'
    + fmt.replace(/:([-\w]{2,})(?:\[([^\]]+)\])?/g, (_, name, arg) => {
      const str = '"\n    + (tokens["' + name + '"](ctx, ';
      return str + String(JSON.stringify(
        arg,
      )) + ') || "-") + "';
    }) + '";';
  /* eslint no-new-func:0 */
  return new Function('tokens, ctx', js);
}
759135
function (t) {
			if(t.type === "function"){
				var fn = "("+helpers.makeParamsString(t.params)+")";
				
				if(t.constructs && t.constructs.types){
					fn = "constructor"+fn;
					fn += " => "+helpers.makeTypes(t.constructs.types)
				} else {
					fn = "function"+fn;
				}
				
				return fn;
			}
			var type = docMap[t.type];
			var title = type && type.title || undefined;
			var txt = helpers.linkTo(t.type, title);
			
			if(t.template && t.template.length){
				txt += "&lt;"+t.template.map(function(templateItem){
					return helpers.makeTypes(templateItem.types)
				}).join(",")+"&gt;";
			}
			if(type){
				if(type.type === "function" && (type.params || type.signatures)){
					var params = type.params || (type.signatures[0] && type.signatures[0].params ) || []
				} else if(type.type === "typedef" && type.types[0] && type.types[0].type == "function"){
					var params = type.types[0].params;
				}
				if(params){
					txt += "("+helpers.makeParamsString(params)+")";
				}
			}
			
			return txt;
		}
1091104
function(template_data, template_name) {
        var precompiled_template,
            regex = /{([^{}]*)}/g;

        // replace double quotes with single quotes
        precompiled_template = template_data.replace(/\"/g, "'");

        // split each line, enclose in double quotes & join them using + sign
        precompiled_template = precompiled_template.split("\n").map(
          function(line) {
            return '"' + line.trim() + '"';
          }).join(" \t+\n ");

        // replace the curly braces with the variables
        precompiled_template = precompiled_template.replace(
          regex, function(a, b) {
            return '" + data.' + b + ' + "';
          });

        return "(function() {\n\t" +
                  "window." + template_namespace + ' = window.' + template_namespace + ' || {};\n\t' +
                  template_namespace + '["' + template_name + '"] = ' + 'function(data) {\n\t\t' +
                    'return ' + precompiled_template + ';\n\t' +
                  '};\n' +
                '})();';
      }
375991
function upgradeTemplate(template, constructor) {
  newInstance = template;
  Object.setPrototypeOf(template, constructor.prototype);
  new constructor();
  newInstance = null;
}
451544
function template(string, data) {
  var proxyRegEx = /\{\{([^\}]+)?\}\}/g;
  return string.replace(proxyRegEx, function(_, key) {
    var keyParts = key.split('.');
    var value = data;
    for (var i = 0; i < keyParts.length; i++) {
      value = value[keyParts[i]];
    }
    return value || '';
  });
}
392084
function(template, values, pattern) {
      pattern = pattern || /\{([^{}]*)\}/g;
      return template.replace(pattern, function(a, b) {
        var p = b.split('.'),
          r = values;
        try {
          for (var s in p) {
            if (p.hasOwnProperty(s)) {
              r = r[p[s]];
            }
          }
        } catch (e) {
          r = a;
        }
        return (typeof r === 'string' || typeof r === 'number') ? r : a;
      });
    }
169911
function compile(template, context) {
        for (var name in context) {
            template = template.replace('{{' + name + '}}', context[name])
        }
        return template
    }
1125454
def parse_template(template, target):
 """"""
 c = ConfManager('')
 for section in template:
  c.add_section(section)
  for option, o in template[section].items():
   try:
    value = type(template[section][option]['value'])(target[section][option])
   except KeyError:
    value = o['value']
   finally:
    if 'value' in o:
     del o['value']
   c.set(section, option, value, **o)
 return c
1225896
def _get_template_dict(template):
    
    if isinstance(template, str):
        return parse_template(template)

    if isinstance(template, dict):
        return copy.deepcopy(template)

    raise ValueError('Input template should be a string or dictionary')
399586
function renderTemplate(template, context) {
    var esc = $(document.createElement('div'));

    function handle(ph, escape) {
      var cur = context;
      $.each(ph.split('.'), function() {
        cur = cur[this];
      });
      return escape ? esc.text(cur || "").html() : cur;
    }

    return template.replace(/<([%#])([\w\.]*)\1>/g, function() {
      return handle(arguments[2], arguments[1] == '%' ? true : false);
    });
  }
1038704
function renderCustomTemplate(body, template, callback) {
  if(typeof callback !== 'function') {
    callback = function(){};
  }

  if(typeof template === 'function') {
    template(body, callback);
  }

  // if(typeof template === 'string') {

  // }
}
77827
function parseStringAttrs(templates, context) {
  var stringAttrs = '';
  var toString = new ToString(true, true);
  for (var i = 0; i < templates.length; i++) {
    toString.clear();
    render(toString, templates[i], context);
    stringAttrs += ' ' + toString.getOutput() + ' ';
  }
  if (whitespaceOnlyRegex.test(stringAttrs)) {
    return null;
  }
  var node = htmlParser('<div ' + stringAttrs + '></div>');
  return node.properties.attributes;
}