harttle / liquidjs

A simple, expressive, safe and Shopify compatible template engine in pure JavaScript.
https://liquidjs.com
MIT License
1.5k stars 237 forks source link

Allow filters to render React components #681

Closed h0jeZvgoxFepBQ2C closed 4 months ago

h0jeZvgoxFepBQ2C commented 4 months ago

Hi,

I would like to do following things:

import React from 'react'
import JsonView from 'react18-json-view'
import 'react18-json-view/src/style.css'

export default function debug(param) {

    return <JsonView 
      src={param}  
      collapsed={1} 
      collapseStringMode="directly" 
      collapseStringsAfterLength={20}
    />
}

class MyClass {
    this.engine = new Liquid();
    this.engine.registerFilter("debug", debugRenderer);
}

const testString = "{{ userparam | debug }}"

But this doesn't work, since it only outputs me "Object [Object]"? And when I use renderToString with import { renderToString } from "react-dom/server"; it works more or less, but its not iteractive (nothing happens when I click on some features)?