This is a very simplified example, but hopefully you get the idea. When building the site, Hugo fails with the error:
"\"" in attribute name: "\" . ($someObject->getSomePropert"
I don’t know what to do to get this working. I’ve tried workarounds. I’ve tried moving the PHP code out into a partial template, and then using safeHTML:
{{ partial "test.php" . | safeHTML }}
{{ safeHTML (partial "test.php" .) }}
Yet it doesn’t make any difference. I just want it to not validate my HTML. Of course it’s not going to be valid HTML. It isn’t plain HTML. It’s HTML mixed in with PHP.
To totally disable HTML validation/sanitation, you would have to look into output formats and the isPlainText setting. Setting that to true for an output format will then use Go’s text templates. This is why JSON templates behaves differently in Hugo.
Using readFile instead of partial bypasses the check entirely, I suppose. Between these two options I can make it work.
As for the “a dash of php” article - I actually read that already. Unfortunately it doesn’t apply to this situation. In that article, they discuss using shortcodes to add in PHP code to content files. In this case, I’m adding PHP to the templates themselves.