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

Use many break tokens. #53

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Use many break tokens. #53

wants to merge 2 commits into from

Conversation

kzaitsev
Copy link

Create new break_tokens attribute, break_token is deprecated.

@parndt
Copy link
Collaborator

parndt commented Jun 17, 2014

Thanks for this, can you please explain this in a little more details?

Also, please can you avoid changing the hash syntax in all of the tests? This makes it really hard to look at history and is unnecessary. 😄

Create new break_tokens attribute, break_token is deprecated.

Signed-off-by: Kirill Zaitsev <[email protected]>
@kzaitsev
Copy link
Author

@parndt Thanks, il change break_token to break_tokens and transform this to array. It simple, we can have more than one break token. I have some projects when changed wysiwyg, and as a consequence pagebreak ( im use it like break token ) changes too. Of course I can change it all pagebreaks :), but i think we can use array of tokens.

@@ -7,11 +7,20 @@ def initialize(original_html, options = {})
@omission = options[:omission] || TruncateHtml.configuration.omission
@word_boundary = (options.has_key?(:word_boundary) ? options[:word_boundary] : TruncateHtml.configuration.word_boundary)
@break_token = options[:break_token] || TruncateHtml.configuration.break_token || nil
@break_tokens = options[:break_tokens] || TruncateHtml.configuration.break_tokens || []
@break_tokens << @break_token
Copy link

Choose a reason for hiding this comment

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

since @break_token can be set to nil on line 9, you may want to add a protection here so you're not shoveling a nil value into your @break_tokens array. maybe something like @break_tokens << @break_token if @break_token.

if there are any nil values in @break_tokens, the code will throw an error at line 83:
NoMethodError - undefined method '<<' for nil:NilClass

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