File size: 470 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
import generators from './Generators.js';
/*
* Match lines starting with `~`
*/
const insert_id = /^~\S*$/gm;
const comment_unknown = (type) => `<!-- Unknown Insertion Type : '${type}' -->`;
function insert(raw) {
const type = toType(raw);
return generators[type]?.() ?? comment_unknown(type);
}
function toType(string) {
return string.trim().substring(1);
}
export default function insertInto(template) {
return template.replace(insert_id, insert);
}
|