Skip to content

Commit

Permalink
Adds a markup parameter to Preprocessors.
Browse files Browse the repository at this point in the history
This parameter will hold the entire processed source file up until the
current preprocessor.

Fixes sveltejs#4912
  • Loading branch information
Maarten van Sambeek committed May 27, 2020
1 parent f46b38a commit aee1054
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/compiler/preprocess/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export type Preprocessor = (options: {
content: string;
attributes: Record<string, string | boolean>;
filename?: string;
markup: string;
}) => Processed | Promise<Processed>;

function parse_attributes(str: string) {
Expand Down Expand Up @@ -103,7 +104,8 @@ export default async function preprocess(
const processed = await fn({
content,
attributes: parse_attributes(attributes),
filename
filename,
markup: source
});
if (processed && processed.dependencies) dependencies.push(...processed.dependencies);
return processed ? `<script${attributes}>${processed.code}</script>` : match;
Expand All @@ -122,7 +124,8 @@ export default async function preprocess(
const processed: Processed = await fn({
content,
attributes: parse_attributes(attributes),
filename
filename,
markup: source
});
if (processed && processed.dependencies) dependencies.push(...processed.dependencies);
return processed ? `<style${attributes}>${processed.code}</style>` : match;
Expand Down

0 comments on commit aee1054

Please sign in to comment.