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

html/template: "stripTags" exportability in the html/template package #5884

Closed
gopherbot opened this issue Jul 14, 2013 · 8 comments
Closed

Comments

@gopherbot
Copy link

by uberjack:

The html/template package has a very handy "stripTags" function
(http://golang.org/src/pkg/html/template/html.go) that's currently unexported. This
function does state-based html stripping which would be very useful as a general-purpose
feature. It would be great to have this function be exported in future releases.
@adg
Copy link
Contributor

adg commented Jul 15, 2013

Comment 1:

If we were to provide it, it should be part of package "html", not "html/template".
It's a pretty odd feature, though. And one you can write more easily using the
code.google.com/p/go.net/html package.
Feel free to copy and paste it where you need it, of course.

@gopherbot
Copy link
Author

Comment 2 by uberjack:

I did (0xe1f/grr@6ddd85b69c59a47abc62cee3bcd662d681f1b4ba),
but sadly it requires a whole set of private classes and functions, and as a result I
ended up importing the entire template package - 11 files.

@gopherbot
Copy link
Author

Comment 3 by lepidosteus:

> It's a pretty odd feature, though.
It's not that useful to display webpages / rendering templates, but it becomes really
handy whenever you need to display the text content of web resources in a non web
context - for example in a cli app - when said resources can have tags embedded in them.
Eg: displaying the content of a rss feed entries (many embed tags in there), listing the
text of all items in an <ul> list on a page (many have
<span>/<strong>/... embedded in the <li>), etc ...
While the function can be copied from "html/template", #2 shows just how much you need
to actually copy (pretty much the entire template package). Having it exported would
make more sense and would be really useful for all of us doing cli apps dealing with web
content

@rsc
Copy link
Contributor

rsc commented Jul 25, 2013

Comment 4:

Status changed to WorkingAsIntended.

@gopherbot
Copy link
Author

Comment 5 by jake.austwick:

+1 for this to be considered. Having to import the entire template package for such a
simple useful function is unreasonable.

@gopherbot
Copy link
Author

Comment 6 by me@rocketmails.net:

+1  Some very common use case is when sending emails as you need to send both text and
HTML versions.

@gopherbot
Copy link
Author

Comment 7 by chris@pushbullet.com:

I've attached a file that does this.

Attachments:

  1. strip.go (113963 bytes)

@earljwagner
Copy link

+1 for StripTags, either in html or html/template.

@mikioh mikioh changed the title "stripTags" exportability in the html/template package html/template: "stripTags" exportability in the html/template package Aug 5, 2015
@golang golang locked and limited conversation to collaborators Sep 22, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants