Devendra174's picture
Upload folder using huggingface_hub
1e92f2d verified
raw
history blame
470 Bytes
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);
}