truncate_html_text 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +3 -0
- data/LICENSE.txt +1 -1
- data/README.md +79 -2
- data/Rakefile +9 -0
- data/lib/test/test_helper_method.rb +9 -0
- data/lib/truncate_html_text/version.rb +1 -1
- data/lib/truncate_html_text.rb +4 -4
- data/truncate_html_text.gemspec +4 -3
- metadata +24 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da1dae46e4b0d66ed6ee47309a50aad00ef15866
|
4
|
+
data.tar.gz: 7635f874a28c14ee1b2527f6c65c5404b5b87ed5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f5a561baac594e7ab8f2ecddc40d454e0d97528814b470aeb41ed362bfcfc2bbeb1d5e6accd75003838984ce9ce215db7a5309d7532199196e08777a029b99c
|
7
|
+
data.tar.gz: 5f8d8f2ca9b64498b72d95bd99bf252417bf3ec49b9e5c6485e38714a97d64328533e3ab7cce413477b3502e3f3210dc957ce3a9f8ebbc0b8eae97e9f055a355
|
data/.travis.yml
ADDED
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,13 @@
|
|
1
|
+
[][gem]
|
2
|
+
[][license]
|
3
|
+
|
4
|
+
[gem]: http://badge.fury.io/rb/truncate_html_text
|
5
|
+
[license]: http://opensource.org/licenses/MIT
|
6
|
+
|
1
7
|
# TruncateHtmlText
|
2
8
|
|
3
|
-
|
9
|
+
This gem allows users to truncate html or non-html text by using options.
|
10
|
+
This gem provides an easy way to integrate `truncate_html_text` jQuery plugin with your Rails apps.
|
4
11
|
|
5
12
|
## Installation
|
6
13
|
|
@@ -20,7 +27,77 @@ Or install it yourself as:
|
|
20
27
|
|
21
28
|
## Usage
|
22
29
|
|
23
|
-
|
30
|
+
To insert JavaScript files in your Rails app, add following line in your `app/assets/javascripts/application.js` file (make sure to add after requiring `jquery`).
|
31
|
+
|
32
|
+
```javascript
|
33
|
+
//= require truncate_html_text_main
|
34
|
+
```
|
35
|
+
|
36
|
+
|
37
|
+
```rails
|
38
|
+
<%= truncate_html_text_tag(:div, '<p>Truncate Html <i>text</i></p>')%>
|
39
|
+
<div class="truncate"><p>Truncate Html <i>text</i></p></div>
|
40
|
+
```
|
41
|
+
|
42
|
+
|
43
|
+
## Options
|
44
|
+
|
45
|
+
Default options are...
|
46
|
+
|
47
|
+
### length
|
48
|
+
|
49
|
+
*Default: Infinity*
|
50
|
+
|
51
|
+
The maximum length (including the ellipsis) of the truncated html.
|
52
|
+
|
53
|
+
```rails
|
54
|
+
<%= truncate_html_text_tag(:div, '<p>Truncate Html <i>text</i></p>', data:{length:20})%>
|
55
|
+
<div class="truncate" data-length="20"><p>Truncate Html <i>t...</i></p></div>
|
56
|
+
```
|
57
|
+
|
58
|
+
### stripTags
|
59
|
+
|
60
|
+
*Default: false*
|
61
|
+
|
62
|
+
If `stripTags` is truthy all html tags will be stipped, leaving only the text.
|
63
|
+
|
64
|
+
```rails
|
65
|
+
<%= truncate_html_text_tag(:div, '<p>Truncate Html <i>text</i></p>', data:{length:20, stripTags: true})%>
|
66
|
+
<div class="truncate" data-length="20" data-stripTags="true">Truncate Html t...</div>
|
67
|
+
```
|
68
|
+
|
69
|
+
### words
|
70
|
+
|
71
|
+
*Default: false*
|
72
|
+
|
73
|
+
If `words` is truthy the input will only be truncated at word boundaries.
|
74
|
+
|
75
|
+
```rails
|
76
|
+
<%= truncate_html_text_tag(:div, '<p>Truncate Html <i>text</i></p>', data:{length:20, words: true})%>
|
77
|
+
<div class="truncate" data-length="20" data-words="true"><p>Truncate Html...</p></div>
|
78
|
+
```
|
79
|
+
|
80
|
+
### noBreaks
|
81
|
+
|
82
|
+
*Default: false*
|
83
|
+
|
84
|
+
If `noBreaks` is truthy the input will contain no break elements.
|
85
|
+
|
86
|
+
```rails
|
87
|
+
<%= truncate_html_text_tag(:div, '<p>Truncate Html <br><i>text</i></p>', data:{length:20, noBreaks: true})%>
|
88
|
+
<div class="truncate" data-length="20" data-noBreaks="true"><p>Truncate Html <i>t...</i></p></div>
|
89
|
+
```
|
90
|
+
|
91
|
+
### ellipsis
|
92
|
+
|
93
|
+
*Default: '…'*
|
94
|
+
|
95
|
+
The `ellipsis` setting is used to provide a different character for the ellipsis.
|
96
|
+
|
97
|
+
```rails
|
98
|
+
<%= truncate_html_text_tag(:div, '<p>Truncate Html <br><i>text</i></p>', data:{length:20, ellipsis: '~'})%>
|
99
|
+
<div class="truncate" data-length="20" data-ellipsis="true"><p>Truncate Html <i>t~</i></p></div>
|
100
|
+
```
|
24
101
|
|
25
102
|
## Contributing
|
26
103
|
|
data/Rakefile
CHANGED
data/lib/truncate_html_text.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
require "truncate_html_text/version"
|
2
|
+
require "truncate_html_text/engine"
|
3
|
+
require "truncate_html_text/truncate_html_text_helper"
|
4
|
+
require "truncate_html_text/railtie"
|
5
5
|
|
6
6
|
#module TruncateHtmlText
|
7
7
|
# Your code goes here...
|
data/truncate_html_text.gemspec
CHANGED
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["Tarun Agrawal"]
|
10
10
|
spec.email = ["tarun7588@gmail.com"]
|
11
11
|
spec.summary = %q{Rails HTML Text Truncate}
|
12
|
-
spec.description = %q{This is a Rails gem for Html Text
|
13
|
-
spec.homepage = ""
|
12
|
+
spec.description = %q{This is a Rails gem for Truncate Html Text}
|
13
|
+
spec.homepage = "https://github.com/iamtarun/truncate_html_text"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0")
|
@@ -18,6 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_development_dependency "bundler",
|
21
|
+
spec.add_development_dependency "bundler", '>= 1.0'
|
22
22
|
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency "minitest"
|
23
24
|
end
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: truncate_html_text
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tarun Agrawal
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
19
|
+
version: '1.0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1.
|
26
|
+
version: '1.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,7 +38,21 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
|
-
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: This is a Rails gem for Truncate Html Text
|
42
56
|
email:
|
43
57
|
- tarun7588@gmail.com
|
44
58
|
executables: []
|
@@ -46,6 +60,7 @@ extensions: []
|
|
46
60
|
extra_rdoc_files: []
|
47
61
|
files:
|
48
62
|
- ".gitignore"
|
63
|
+
- ".travis.yml"
|
49
64
|
- Gemfile
|
50
65
|
- LICENSE.txt
|
51
66
|
- README.md
|
@@ -53,13 +68,14 @@ files:
|
|
53
68
|
- app/assets/javascripts/truncate_html_text.js
|
54
69
|
- app/assets/javascripts/truncate_html_text_initializer.js
|
55
70
|
- app/assets/javascripts/truncate_html_text_main.js
|
71
|
+
- lib/test/test_helper_method.rb
|
56
72
|
- lib/truncate_html_text.rb
|
57
73
|
- lib/truncate_html_text/engine.rb
|
58
74
|
- lib/truncate_html_text/railtie.rb
|
59
75
|
- lib/truncate_html_text/truncate_html_text_helper.rb
|
60
76
|
- lib/truncate_html_text/version.rb
|
61
77
|
- truncate_html_text.gemspec
|
62
|
-
homepage:
|
78
|
+
homepage: https://github.com/iamtarun/truncate_html_text
|
63
79
|
licenses:
|
64
80
|
- MIT
|
65
81
|
metadata: {}
|