Skip to content

Commit

Permalink
Update liquid-parser.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
scopsy committed Jan 6, 2025
1 parent b76fbfa commit a88ba03
Showing 1 changed file with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Template, Liquid, RenderError, LiquidError } from 'liquidjs';
import { isValidTemplate, extractLiquidExpressions } from './parser-utils';
import { Liquid, LiquidError, RenderError, Template } from 'liquidjs';
import { extractLiquidExpressions, isValidTemplate } from './parser-utils';

const LIQUID_CONFIG = {
strictVariables: true,
Expand All @@ -8,12 +8,6 @@ const LIQUID_CONFIG = {
catchAllErrors: true,
} as const;

// Create a parser engine with digest filter for validation
const parserEngine = new Liquid(LIQUID_CONFIG);

// Register digest filter for validation
parserEngine.registerFilter('digest', () => '');

export type Variable = {
/**
* The variable name/path (e.g. for valid variables "user.name",
Expand Down Expand Up @@ -129,6 +123,11 @@ function processLiquidRawOutput(rawOutputs: string[]): TemplateVariables {
}

function parseByLiquid(rawOutput: string): TemplateVariables {
const parserEngine = new Liquid(LIQUID_CONFIG);

// Register digest filter for validation of digest transformers
parserEngine.registerFilter('digest', () => '');

const validVariables: Variable[] = [];
const invalidVariables: Variable[] = [];
const parsed = parserEngine.parse(rawOutput) as unknown as Template[];
Expand Down

0 comments on commit a88ba03

Please sign in to comment.