Skip to content

Commit 8a833ba

Browse files
committed
Make getDefaultTemplateRenderer internal
1 parent 076874f commit 8a833ba

2 files changed

Lines changed: 15 additions & 17 deletions

File tree

index.d.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ export interface PMEConfig<T = LiquidOptions> {
4545
pdfOptions?: PDFOptions;
4646

4747
/**
48-
* Sets up and returns a function that renders HTML from a template string and data
49-
* object.
48+
* Sets up and returns a function that renders HTML from a template string and
49+
* data object.
5050
*/
5151
getTemplateRenderer?(options?: T): RenderTemplate;
5252
}
@@ -153,13 +153,6 @@ export function renderHTML(
153153
data?: object
154154
): Promise<string>;
155155

156-
/**
157-
* @returns The default Liquid renderer.
158-
*/
159-
export function getDefaultTemplateRenderer(
160-
options?: LiquidOptions
161-
): RenderTemplate;
162-
163156
/**
164157
* Encodes `html` into a Data URL.
165158
*

index.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,9 @@ export async function getBuilder() {
110110
const html = await renderHTML(
111111
absolutizePath(template, rootDir),
112112
(options?.getTemplateRenderer ?? getDefaultTemplateRenderer)(
113-
// TODO: Fix type error
113+
// This should be fine as long as 'T' is set when using a custom
114+
// renderer and left to the default 'LiquidOptions' when using the
115+
// default renderer.
114116
// @ts-expect-error
115117
options?.templateOptions
116118
),
@@ -142,6 +144,16 @@ export async function getBuilder() {
142144
};
143145
}
144146

147+
/**
148+
* @param {import("liquidjs/dist/liquid-options").LiquidOptions} [options]
149+
* @returns {import("./index").RenderTemplate}
150+
*/
151+
function getDefaultTemplateRenderer(options) {
152+
const liquid = new Liquid(options);
153+
154+
return (template, data) => liquid.parseAndRender(template, data);
155+
}
156+
145157
/** @type {import("./index").getData} */
146158
export async function getData(path) {
147159
if (typeof path !== "string") {
@@ -210,13 +222,6 @@ export async function renderHTML(path, render, data) {
210222
return render(await fs.readFile(path, "utf-8"), data);
211223
}
212224

213-
/** @type {import("./index").getDefaultTemplateRenderer} */
214-
export function getDefaultTemplateRenderer(options) {
215-
const liquid = new Liquid(options);
216-
217-
return (template, data) => liquid.parseAndRender(template, data);
218-
}
219-
220225
/** @type {import("./index").encodeHTML} */
221226
export function encodeHTML(html) {
222227
if (typeof html !== "string") {

0 commit comments

Comments
 (0)