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

striptags seem to no longer work #286

Closed
piedoom opened this issue Apr 11, 2018 · 7 comments
Closed

striptags seem to no longer work #286

piedoom opened this issue Apr 11, 2018 · 7 comments

Comments

@piedoom
Copy link
Contributor

piedoom commented Apr 11, 2018

I was in the process of updating a theme from using 0.2.2 to 0.3.3.

Version 0.2.2
image

Version 0.3.3
image

Both have this code:

{{ page.content | striptags | truncate }} 

However, it seems as though 0.3.3 doesn't strip tags. This doesn't work either:

{{ page.content | striptags }} 
@Libbum
Copy link
Contributor

Libbum commented Apr 11, 2018

I'm not sure if this is a version change thing, but from the looks of what you're trying to do here—using | safe might have the desired effect.

@Keats
Copy link
Collaborator

Keats commented Apr 11, 2018

I think so too, {{ page.content | safe | striptags }} should work as, without safe, the text has escaped tags, not tags.

@piedoom
Copy link
Contributor Author

piedoom commented Apr 11, 2018

Cool! I try that. I'm wondering, would it be more ergonomic to have striptags implicity call safe? I can't imagine a use case where safe wouldn't need to be called.

@Keats
Copy link
Collaborator

Keats commented Apr 13, 2018

would it be more ergonomic to have striptags implicity call safe

Not sure about that, I'm not a big fan of implicit behaviours

@Libbum
Copy link
Contributor

Libbum commented Apr 13, 2018

Yeah, verbosity is probably more important than ergonomics here. Just because there isn't a specific use case now (or at least not one off the top of my head), no doubt someone in the future is going to find it. When that happens it's something that'll need to be separated or split off into another function or a similar extension akin to | not_safe | striptags would need to be invented.

A better solution (if you think it's needed) would be extending the documentation so if others come up against the issue they won't get stuck.

@piedoom
Copy link
Contributor Author

piedoom commented Apr 13, 2018

Fair enough. However, I can't imagine a use-case now or in the future that would require striptags without safe. It doesn't make sense to me as it always requires content to have tags, otherwise it does nothing. I'm very much in favor of eliminating implicit behavior, but explicit for the sake of avoiding small implicit things is counter-intuitive, IMO. I'm wondering, was the opposite behavior shown in the version 0.2.2 was a bug, or a decision that was reverted in future updates?

@piedoom piedoom closed this as completed Apr 13, 2018
@Keats
Copy link
Collaborator

Keats commented Apr 14, 2018

I updated the docs in Keats/tera@1f64ef4 that will be published for the next Tera release

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

No branches or pull requests

3 participants