Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Add plainify template function #1915
@bep Working on your suggestion above, but this is getting a little more discourse-appropriate, so I'll comment here instead: https://discuss.gohugo.io/t/possible-to-get-markdown-escaped-as-just-plain-text-if-not-json/2607
Did some research on what others do. Django and Jinja2 call this
Why do you make it "safe" (return
My point about the name was that "plain" isn't very descriptive or intuitive to me. Our existing -ify funcs (where I use renderer very loosely):
More intuitive options:
I reviewed the code and it's good.
As for the name, at first I was inclined to agree with @bep's validation for the name as it's consistent with other things we have. In using the function it felt wrong and the name did confuse me.
I think it should be called either stripTags or stripHTML.
I have a few reasons for this:
The function being called inside of this (and inside Plain) is helpers.StripHTML which feels like the right descriptive name for what it is doing.
In retrospect, the helpers.StripHTML should have been named StripTags, but as it was only being used for HTML the name is accurate enough.
Well, I don't agree - the other ify functions are also transformers, they transform a piece of content from a state/format to another. So does this. The interface of
Feel free to add another template function with a more specific use case, but this isn't that function.
Maybe we should have a
The only thing I agree about here is that it it reads bad as a verb. But that is also true for jsonify, emojify etc. i.e. all of them. But the value of the naming convention makes up for the stupidity.