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

Add a helper to strip HTML tags #179

Closed
wants to merge 1 commit into from
Closed

Add a helper to strip HTML tags #179

wants to merge 1 commit into from

Conversation

LaurentGoderre
Copy link
Contributor

No description provided.

@LaurentGoderre
Copy link
Contributor Author

/cc @shawnthompson

@jonschlinkert
Copy link
Member

@LaurentGoderre can you do this PR against the v0.6.0 branch? we're going to be merging any day now. thx!

@LaurentGoderre
Copy link
Contributor Author

@jonschlinkert will we still be able to use it on v0.4.x?

@jonschlinkert
Copy link
Member

hmm, if we merge into the current branch, would you be okay with doing another pr afterwards to merge into v0.6.0? we wouldn't be able to merge it otherwise, the versions are too different. @doowb any problems with that?

@LaurentGoderre
Copy link
Contributor Author

Absolutely

@doowb
Copy link
Member

doowb commented Feb 27, 2015

That sounds good to me.

* @param {[type]} options [description]
* @return {[type]} Text with HTML tags removed
*/
striptags: function (options) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@doowb @jonschlinkert is options right her or should it be context? I never know

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

options are what handlebars passes as the last argument automatically. If you're planning on passing in a context when using the helper in a template, then you want to do striptags: function (context, options) {.

Your test below says {{#striptags context options}} but it's not actually testing that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 to add a little more to what @doowb mentioned (b/c it took me forever to remember these), when you do console.log() on those objects, if you see hash, it's really the options object that is created by Handlebars, with additional properties that handlebars creates, like root. But context is the actual data object that is being built-up from various sources to pass to your templates. Both of these objects can be merged inside the helper function. Hope that helps (or maybe it made it worse lol)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't merge this just yet, give me a minute I'll add some comments. I think we need to make this a little more robust.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we could just get a couple more unit tests before merging to ensure it won't hang on unclosed tags or code comments. does that work for you guys?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you unclosed tags do you mean <a this is a link or <a href="">this is a link?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exactly, the first example.

@doowb
Copy link
Member

doowb commented Mar 30, 2017

There's a sanitize helper that does this for a passed in string.

If you still need something like this for block helpers, please submit a new PR since this was against an older version.

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

Successfully merging this pull request may close these issues.

3 participants