feat: allow plugins to modify HTML body (#2022)
Based on https://github.com/denoland/fresh/pull/1769 . Mostly added a test. --------- Co-authored-by: Adam Gregory <adam@aguilaengineering.com>
This commit is contained in:
co-authored by
Adam Gregory
parent
14cecc0a6f
commit
7ff2781fcd
@@ -276,6 +276,10 @@ export async function render<Data>(
|
||||
);
|
||||
}
|
||||
renderResults.push([plugin, res]);
|
||||
|
||||
if (res.htmlText !== undefined) {
|
||||
bodyHtml = res.htmlText;
|
||||
}
|
||||
} else {
|
||||
bodyHtml = renderHtml(renderState);
|
||||
}
|
||||
@@ -308,6 +312,10 @@ export async function render<Data>(
|
||||
`The 'renderAsync' function was not called by ${plugin?.name}'s async render hook.`,
|
||||
);
|
||||
}
|
||||
|
||||
if (res.htmlText !== undefined) {
|
||||
bodyHtml = res.htmlText;
|
||||
}
|
||||
} else {
|
||||
await opts.renderFn(ctx, () => renderSync().htmlText);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user