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

Integrate sprig for improved templating #9

Merged
merged 8 commits into from Aug 16, 2021
Merged

Conversation

mntn-xyz
Copy link
Contributor

Currently templates are fairly limited, with only the built-in Go template functions and the one sortPosts helper function. I am working on templates for my own site and needed something equivalent to sprig's hasPrefix, as I wanted to display every post under a specified path, including posts from nested subdirectories. (I am working on making Hugo branch and leaf nodes work; these currently don't seem to work beyond the first level.)

Sprig provides functions for displaying the current date, string manipulation, and plenty more. This would be an easy way to expand the functionality of the Gemtext templates. The chief downside is that it adds a few dependencies.

@tdemin
Copy link
Owner

tdemin commented Aug 16, 2021

@mntn-xyz this looks good, thank you!

It looks like you haven't run go mod tidy yet? Building/testing the code right now will fail because of go.sum / go.mod mismatch.

PS: I initially thought about adding Sprig in because I wanted to write as little custom helpers as possible, but ended up not doing it. :P

@mntn-xyz
Copy link
Contributor Author

Thanks, I am still new to go... the syntax is straightforward, but I need to read up on the tooling!

@tdemin tdemin merged commit 0ac0476 into tdemin:master Aug 16, 2021
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 this pull request may close these issues.

None yet

2 participants