slim-grunt-helpers 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -1
- data/lib/slim-grunt-helpers/models/usemin.rb +12 -4
- data/lib/slim-grunt-helpers/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d566aa9db2ec0e20872d9d84f75b8c828d544774
|
4
|
+
data.tar.gz: a61fb1704ca4ad4a3e322d31cdc6888813739040
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e779274082e12e0ad0f2f748f2264f308bd150a04b3b5316b86ade8e1fb41b4f9b48b4947f4869bec7f4ca9e5b2b71286beedecd6c4b7b5bd53de3ab5bd1e92f
|
7
|
+
data.tar.gz: 09d78f7bd69ba051f3a1e1b5d7824b3a771fce06a9247f271bb0c098d2346ca998b20e5a812141fab3f0e307b75c378b40abaf316dab7d45a7b0771b0b980ad4
|
data/README.md
CHANGED
@@ -50,9 +50,10 @@ there which are boring to type directly in Slim. The usage is simple:
|
|
50
50
|
== sg_usemin_css('application.css', alt: '.tmp') do |usemin|
|
51
51
|
- usemin << 'styles/bootstrap.css'
|
52
52
|
- usemin.add 'styles/main.css', 'data-customattr' => 'customdata'
|
53
|
+
- usemin.include 'styles/secondary.css', 'data-customattr' => 'customdata'
|
53
54
|
```
|
54
55
|
|
55
|
-
**Note:** You can either use **<<
|
56
|
+
**Note:** You can either use **<<**, `add` or `include`, I prefer the first one but if you want use two params,
|
56
57
|
the only way to do it is in this way:
|
57
58
|
```ruby
|
58
59
|
- usemin.<<('param1', 'data-customattr' => 'customdata')
|
@@ -73,6 +74,15 @@ hash of options which are appended as attributes to the link tag. Notice that on
|
|
73
74
|
`rel="stylesheet"` is automatically appended (and can be overwritten by specifying a `rel` key in options).
|
74
75
|
Additionally, notice that attributes with `nil` or `false` as value are not set (so you can remove `rel`), while those with `true` are set but without value and without `=""`.
|
75
76
|
|
77
|
+
## usemin.require and usemin.require_tree
|
78
|
+
`require` allows to include files only if they are not already included. Uses same params as `include`.
|
79
|
+
`require_tree` instead, require an entire directory tree, using [Dir glob](http://ruby-doc.org/core-1.9.3/Dir.html#method-c-glob) pattern. It accepts the following parameters:
|
80
|
+
|
81
|
+
- `root_path` which is the path will be used as base directory (and **omitted in tags**)
|
82
|
+
- `pattern` which is the pattern accepted by [Dir glob](http://ruby-doc.org/core-1.9.3/Dir.html#method-c-glob), used to search files
|
83
|
+
- `relative` which if it's true, ensures file path won't start with `/` when printed in html
|
84
|
+
- `options` which are directly passed to `require`
|
85
|
+
|
76
86
|
## Contributing
|
77
87
|
|
78
88
|
1. Fork it
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
|
1
3
|
module SlimGruntHelpers
|
2
4
|
|
3
5
|
module Models
|
@@ -28,12 +30,18 @@ module SlimGruntHelpers
|
|
28
30
|
BASE_OPTIONS
|
29
31
|
end
|
30
32
|
|
31
|
-
def require_tree(root_path, pattern, options={})
|
32
|
-
|
33
|
+
def require_tree(root_path, pattern, relative=false, options={})
|
34
|
+
unless root_path.respond_to? :join
|
35
|
+
root_path = Pathname.new(root_path.to_s)
|
36
|
+
end
|
37
|
+
|
38
|
+
Dir[root_path.join(pattern).to_s].reject do |file|
|
33
39
|
File.directory? file
|
34
40
|
end.each do |file|
|
35
|
-
file_name
|
36
|
-
|
41
|
+
file_name = file.to_s
|
42
|
+
real_root_path = root_path.to_s
|
43
|
+
real_root_path += '/' if relative
|
44
|
+
file_name[real_root_path] = ''
|
37
45
|
|
38
46
|
self.require file_name, options
|
39
47
|
end
|