question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Access the list of render errors

See original GitHub issue

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!

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
harttlecommented, Apr 24, 2020

An additional method or a catchAllErrors defaults false or failFast defaults true argument will be better, or this feature will be a breaking change.

2reactions
bbughcommented, Apr 23, 2020

Great, thank you for confirming my assumptions. If we decide to move forward with the client-side approach, I will see about a PR. It looks like handling errors happens in renderTemplates. It seems like that could return an object instead of a string, like { result: string, errors: LiquidError[] }. So as not to break the end-user API, the render function could still return a string, but keep the errors in engine. Does that seem plausible or am I way off?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to fix error when trying to render a list - Stack Overflow
To access the results, use setData(response.data?.results) to set the value for data in your state if you only need result[] to MovieCard ...
Read more >
Fix export issues in Premiere Pro - Adobe Support
Application hangs, freezes, or becomes unresponsive while rendering or exporting? We're here to help! Fix common export issues in 7 simple steps ...
Read more >
A Guide to Common React Errors
The Ultimate React Errors Guide. In this guide we try to explain every React error you might run into. There's a mix of...
Read more >
Error Boundaries - React
Error boundaries catch errors during rendering, in lifecycle methods, ... Use static getDerivedStateFromError() to render a fallback UI after an error has ...
Read more >
8 common React error messages and how to address them
Sometimes, you won't have a unique identifier attached to your data. An easy fix is to use the index of the current item...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found