Skip to content

Access the list of render errors #220

Closed
@bbugh

Description

@bbugh

Hi! 👋 This seems like a great library.

We're using liquid-ruby for our customers to be able to customize some of their templates. We want to use liquidjs to do client-side previews and error parsing, so we can give the customers fast feedback while avoiding a round-trip to our server's precious resources.

In Ruby liquid, when rendering a template, an array of the errors is available afterwards, which can be used to display to the client. I've looked through the docs/repo, and liquidjs seems to behave very differently from liquid-ruby in this way.

Ruby example:

options = options = { strict_variables: true, strict_filters: true }
template = Liquid::Template.parse(markup)
result = template.render(context, options)

# Lots of errors to look at here
template.errors.each do |error|
  puts error
end

With the same markup and options as the Ruby version, liquidjs throws one error and quits.

const engine = new Liquid()
const template = engine.parse(markup)

// This throws a single error
const result = engine.renderSync(template, {}, { strictFilters: true, strictVariables: true })

I'm surprised this doesn't exist yet, but I'm guessing liquidjs is used more for server templates?

Is this possible to do with liquidjs or are we out of luck? Thanks!

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions