16 lines
533 B
JavaScript
16 lines
533 B
JavaScript
import { helper } from '@ember/component/helper';
|
|
|
|
export function optionTextExp([option, valueField, textField, textExp]) {
|
|
const text = option[textField];
|
|
return textExp ? textExp.replace('$value', option[valueField])
|
|
.replace('$text', text)
|
|
.replace(/\$\.\w+/g, (field) => option[field.replace('$.', '')] || '') : text;
|
|
|
|
// '1234567890'.replace(/\d/g, function(c) {
|
|
// return ['零', '一', '二', '三', '四', '五', '六', '七', '八', '九'][parseInt(c)];
|
|
// });
|
|
|
|
}
|
|
|
|
export default helper(optionTextExp);
|