map rendered strings to template token source
This commit is contained in:
8
index.ts
8
index.ts
@@ -1,6 +1,8 @@
|
||||
import { z } from "zod"
|
||||
import { parse, type TemplateVariable } from "./parser"
|
||||
import { renderDir } from "./render"
|
||||
import { renderDir, type RenderOptions } from "./render"
|
||||
|
||||
export type { RenderOptions, ReverseMapFile, ReverseMapManifest, ReverseMapToken } from "./render"
|
||||
|
||||
interface Stringable {
|
||||
toString: () => string
|
||||
@@ -85,9 +87,9 @@ export const initRenderer = (dirPath: string) => {
|
||||
|
||||
const createRenderer = <S extends z.ZodType>(userSchema: S) => {
|
||||
validateSchemaMatchesTemplates(userSchema, variables)
|
||||
return (targetPath: string, context: z.infer<S>) => {
|
||||
return (targetPath: string, context: z.infer<S>, options?: RenderOptions) => {
|
||||
userSchema.parse(context)
|
||||
renderDir(dirPath, targetPath, context as Record<string, unknown>)
|
||||
renderDir(dirPath, targetPath, context as Record<string, unknown>, options)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user