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

Truncate sanitizer #163

Closed
adrianbj opened this Issue Mar 9, 2018 · 3 comments

Comments

Projects
None yet
3 participants
@adrianbj

adrianbj commented Mar 9, 2018

Short description of the enhancement

Add a truncate() method to the sanitizer class.

Current vs. suggested behavior

Maybe the sanitizer class isn't the right place for it - maybe just a public function: wireTruncate() or something?

Why would the enhancement be useful to users?

I think this is a very common need and it would be nicer than using our own versions.

Optional: Screenshots/Links that demonstrate the enhancement

I think you could make use of this function:
https://github.com/processwire/processwire/blob/57b297fd1d828961b20ef29782012f75957d6886/wire/modules/Markup/MarkupRSS.module#L181

@teppokoivula

This comment has been minimized.

teppokoivula commented Mar 10, 2018

Definitely makes sense. This is something that I've needed on every ProcessWire site I've built so far, more or less. Makes sense not to reinvent the wheel every single time :)

@rolandtoth

This comment has been minimized.

rolandtoth commented Mar 11, 2018

It would be nice if it could take html tags into account, but using strip_tags is also better than nothing.

In my Latte module I'm using this code, perhaps it can help too:
https://github.com/rolandtoth/TemplateLatteReplace/blob/b7d6402bb9b39b90ccdd24b36e3343d92aa2a8f5/_filters.php#L1359

@adrianbj

This comment has been minimized.

adrianbj commented May 4, 2018

Brilliant - thanks @ryancramerdesign

@adrianbj adrianbj closed this May 4, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment