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

tpl/tplimpl: Fix context in shortcode error messages #13281

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jmooring
Copy link
Member

Fixes #13279

OK, so this PR does a bit more than advertised, primarily moving the shortcode integration tests into their own file, and adding a few more.

For shortcodes that render more than a few lines, these tests compare content hashes. It may take a little more time to figure out why one of these tests fails in the future, but this does a much better job of detecting the failure.


// Regular mode
b := hugolib.Test(t, files)
b.AssertFileContentEquals("public/index.html", "a7937c49665872d3")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, I like the concept of using hashes here, but I suspect I'm going to get bitten by the lack of output at some point.

I suggest that we print both the hash and the content, e.g.

Hash: {{ .Content | hash.XxHash }}
Content: {{ .Content }}

And then do:

b.AssertFileContent("public/index.html", "a7937c49665872d3")

The test will be as robust as before, but we will get better output on failures.

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.

Fix context issue with some embedded templates
2 participants