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

Custom tag support #41

Closed
jalcine opened this issue Jul 28, 2020 · 4 comments · Fixed by #42
Closed

Custom tag support #41

jalcine opened this issue Jul 28, 2020 · 4 comments · Fixed by #42
Milestone

Comments

@jalcine
Copy link
Contributor

jalcine commented Jul 28, 2020

Hey there! I've been working to move https://koype.net/ to use this library over the unmaintained https://github.com/bettyblocks/liquid-elixir. It did work well but I had support for providing custom tags. It looks like this uses nimble-parsec so I'm not sure what would be required to extend this so custom tag support could be a tag. My use case was allowing templates to look up routes in my Phoenix application.

@edgurgel edgurgel added this to the Solid 1.0 milestone Jul 28, 2020
@edgurgel
Copy link
Owner

Thanks for opening this ticket. I would love to support custom tags! I'm not sure either how we would support custom tags. Maybe one way is to allow the parser to include custom tags before it compiles? 🤔 Now I'm curious 😆

@jalcine
Copy link
Contributor Author

jalcine commented Jul 31, 2020

That’s how the other Elixir library handled it. At https://github.com/bettyblocks/liquid-elixir#custom-tags-and-filters, it’d either done via configuration or passing it in upon template compilation. It might have to be another argument or something passed into how Solid.Parser builds up its support. I’m looking into nimble_parsec now but it looks like being able to define if it has a closing tag (for block tags) and a way to pass in a string that can be processed as an argument list would work.

This post https://blog.sverrirs.com/2016/04/custom-jekyll-tags.html has some ideas on ideas, based on Jekyll. Personally, giving the argument string as is to the tag would be the simplest (maybe some serialization facilities could be built for people but not a requirement to ship)

(Originally published at: https://v2.jacky.wtf/post/f7f801b5-ad69-45ba-9c16-d9122994d8c4)

@jalcine jalcine mentioned this issue Aug 6, 2020
3 tasks
@jalcine
Copy link
Contributor Author

jalcine commented Aug 9, 2020

Got a PR working with this. The idea is that on the call to render; one would pass in a map of tag names that would be detected in the code whose values map to modules that can probably implement a behavior for a tag. This covers my particular use case and matches a leaner approach that the other Elixir Liquid library satisfied.

(Originally published at: https://v2.jacky.wtf/post/e70ac05d-6535-4b66-874f-a7d9e262ae0d)

@edgurgel
Copy link
Owner

edgurgel commented Aug 9, 2020

Great! Thanks for the PR! I will review it later today 👍

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

Successfully merging a pull request may close this issue.

2 participants