UNPKG

xe-utils

Version:

JavaScript 函数库、工具类

14 lines (12 loc) • 603 B
import setupDefaults from './setupDefaults.js';import helperStringReplace from './helperStringReplace.js';import toValueString from './toValueString.js';import trim from './trim.js';import get from './get.js';/** * 解析动态字符串模板 * @param {atring} str 字符串模板 * @param {any | any[]} args 对象 * @param {any} options */ function template (str, args, options) { return helperStringReplace(toValueString(str), (options || setupDefaults).tmplRE || /\{{2}([.\w[\]\s]+)\}{2}/g, function (match, key) { return get(args, trim(key)) }) } export default template