Rendering Liquid from a variable

Hi, is it possible to store Liquid code in a variable and then render it programmatically?

The goal is that the Liquid code will come from a field in the app, merchant provided liquid code of course, stored in a metafield, then rendered as the schema field “custom_liquid” does.

Have you tried with liquid Render(Sections)

Thank you for your answer @kahn.

For the static section rendering, the Liquid code needs to be stored in a file inside the theme.

In my case, I have the Liquid inside a metafield say shopf.metafields.custom.liquid.

@junaidkbr Regarding the use case of an app, I believe you could utilize a theme app extension with an app block or app embed block for allowing a merchant to include Liquid code.

Regarding the usable input settings I believe only color scheme related settings are not usable within app blocks or app embed blocks, or at least that is the way they are currently documented from what I can tell.

Currently there is no metafield suitable for Liquid content.

Hello @junaidkbr ,
No, Liquid doesn’t support rendering Liquid code stored in a variable or metafield at runtime. Liquid is a secure, compiled template language, so Shopify doesn’t allow dynamic evaluation (eval-like behavior) for security and performance reasons.

Thanks guys for responding. I am concluding that there’s no way of rendering/executing Liquid code from a variable/metafield.

There’s one way to accomplish Liquid rendering/execution and that is to serve the Liquid code via app proxy.

xyproblem, what is the actual goal
Directly render a block of liquid logic conditionals no.
If trying to output objects just use a JSON metafield

There’s also using theme app extensions, which if the code is static can be deployed once so wont need a server constantly running.