Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(How) Is it possible to get all available liquid variables from a template? #80

Closed
dkbast opened this issue Jul 25, 2018 · 6 comments
Closed
Labels

Comments

@dkbast
Copy link

dkbast commented Jul 25, 2018

I have a scenario where I have multiple liquid themes which can be interchanged. Instead of a dynamic database I use a CSV file, so I have to know all the variables upfront.
Let me explain this with a simplified example:

For these three Themes:
Theme 1:
title
text
image

Theme 2:
title
text
image

Theme 3:
image
subtitle

I would like to get the output of: title, text, image, subtitle

Is there a builtin routine I have missed? What would be the best way for accomplishing this?

@harttle
Copy link
Owner

harttle commented Jul 25, 2018

As far as I know, there's no such feature in the Liquid template language. See Shopify/liquid#685 But it's possible to achieve this by registering a custom tag/filter

@timuster
Copy link

@harttle With this now being supported in Liquid (see this comment), is there any way to make it work with LiquidJS?

@harttle
Copy link
Owner

harttle commented Jan 26, 2022 via email

@FrankHeijden
Copy link

I am also looking for this feature, my use case is that I have to fetch an object as a variable, being able to know which variables are being referenced on that object would help greatly with only fetching what is necessary :)

@FrankHeijden
Copy link

nvm, just found out about this discussion: #528
apparently there exists a content field on Token, however it is not defined in the type:
Screenshot 2023-01-22 at 16 16 36

@harttle
Copy link
Owner

harttle commented Jan 26, 2023

@FrankHeijden I believe you came across a DelimitedToken which is a subclass of Token.

I created a PR for astexplorer fkling/astexplorer#680 , hopefully one day it'll be available on https://astexplorer.net/ website.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants