mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Add template renderer for extensions
This commit is contained in:
@ -496,9 +496,10 @@ function getUrlSync(url, cache = true) {
|
||||
}).responseText;
|
||||
}
|
||||
|
||||
function renderTemplate(templateId, templateData = {}, sanitize = true, localize = true) {
|
||||
export function renderTemplate(templateId, templateData = {}, sanitize = true, localize = true, fullPath = false) {
|
||||
try {
|
||||
const templateContent = getUrlSync(`/scripts/templates/${templateId}.html`);
|
||||
const pathToTemplate = fullPath ? templateId : `/scripts/templates/${templateId}.html`;
|
||||
const templateContent = getUrlSync(pathToTemplate);
|
||||
const template = Handlebars.compile(templateContent);
|
||||
let result = template(templateData);
|
||||
|
||||
|
Reference in New Issue
Block a user