repolho 0.1.2 → 0.1.3
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
- checksums.yaml.gz.sig +3 -1
- data/README.md +54 -0
- data/lib/repolho/version.rb +1 -1
- data/lib/repolho.rb +13 -0
- data.tar.gz.sig +0 -0
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7315e78763de32bb1edec0e9ad337fd3ce360d189bee8ad978b4305120b181bd
|
|
4
|
+
data.tar.gz: 50f94f0d3227d78d60da48b6e808161aae2a6445a9dbc911f3e6c4b300fb97e5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6e77ee42e3d53fd9cbab4183159810e54ec3f5422ed224ec74c4e6302bdf3f41b878046e393ec5e4df536aba9322d552a20a29aa4802402224892a716a85f8c2
|
|
7
|
+
data.tar.gz: aa3025ab2b9e9437b0bd56307deb39215c068b65857926a1fddac26d72e87243665812e34c7ede99fea32c12f8c450246e3d5b7e1edc9af0d446dcf4a2a77eb7
|
checksums.yaml.gz.sig
CHANGED
data/README.md
CHANGED
|
@@ -230,8 +230,62 @@ To preview the structure, rename the file to `.html` and open it in a browser
|
|
|
230
230
|
| `count(:field)` | Number of values |
|
|
231
231
|
| `number` | Current page or group number |
|
|
232
232
|
|
|
233
|
+
## Rails helpers
|
|
234
|
+
|
|
235
|
+
You can make Rails view helpers available inside the ERB templates by calling
|
|
236
|
+
`Repolho.include_rails_helpers!`. By default it includes
|
|
237
|
+
`ActionView::Helpers::NumberHelper` (so you get `number_to_currency`,
|
|
238
|
+
`number_with_precision`, etc.).
|
|
239
|
+
|
|
240
|
+
### Inside a Rails application
|
|
241
|
+
|
|
242
|
+
```ruby
|
|
243
|
+
# config/initializers/repolho.rb
|
|
244
|
+
Repolho.include_rails_helpers!
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
After that you can use the helpers normally in any template:
|
|
248
|
+
|
|
249
|
+
```erb
|
|
250
|
+
<td class="text-end"><%= number_to_currency(attr(:value)) %></td>
|
|
251
|
+
<td><%= number_with_precision(sum(:value), precision: 2) %></td>
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
You can also pass extra modules:
|
|
255
|
+
|
|
256
|
+
```ruby
|
|
257
|
+
Repolho.include_rails_helpers!(
|
|
258
|
+
ActionView::Helpers::NumberHelper,
|
|
259
|
+
ActionView::Helpers::TextHelper
|
|
260
|
+
)
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
### Outside Rails
|
|
264
|
+
|
|
265
|
+
You need the corresponding gems and must require them before calling the method:
|
|
266
|
+
|
|
267
|
+
```ruby
|
|
268
|
+
# Gemfile
|
|
269
|
+
gem "actionview"
|
|
270
|
+
# or, if you prefer the lower-level helpers:
|
|
271
|
+
# gem "activesupport"
|
|
272
|
+
|
|
273
|
+
require "action_view/helpers/number_helper"
|
|
274
|
+
Repolho.include_rails_helpers!
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
Instance variables from the Rails view (such as `@current_template`) are not
|
|
278
|
+
automatically copied. Pass them explicitly through the `locals` hash:
|
|
279
|
+
|
|
280
|
+
```ruby
|
|
281
|
+
Repolho::Main.new(path, data, current_template: @current_template, user: current_user)
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
They become `@current_template` and `@user` inside the templates.
|
|
285
|
+
|
|
233
286
|
## Signing
|
|
234
287
|
|
|
288
|
+
|
|
235
289
|
This gem is cryptographically signed. To verify the signature on install:
|
|
236
290
|
|
|
237
291
|
```bash
|
data/lib/repolho/version.rb
CHANGED
data/lib/repolho.rb
CHANGED
|
@@ -8,4 +8,17 @@ require_relative "repolho/report"
|
|
|
8
8
|
require_relative "repolho/main"
|
|
9
9
|
|
|
10
10
|
module Repolho
|
|
11
|
+
# Includes Rails helper modules into Container so they become available
|
|
12
|
+
# in ERB templates (headers, footers, rows, previous and after).
|
|
13
|
+
#
|
|
14
|
+
# By default includes ActionView::Helpers::NumberHelper.
|
|
15
|
+
# Pass additional modules if needed.
|
|
16
|
+
#
|
|
17
|
+
# Example:
|
|
18
|
+
# Repolho.include_rails_helpers!
|
|
19
|
+
# Repolho.include_rails_helpers!(ActionView::Helpers::NumberHelper, ActionView::Helpers::TextHelper)
|
|
20
|
+
def self.include_rails_helpers!(*modules)
|
|
21
|
+
modules = [ActionView::Helpers::NumberHelper] if modules.empty?
|
|
22
|
+
modules.each { |mod| Container.include(mod) }
|
|
23
|
+
end
|
|
11
24
|
end
|
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
metadata.gz.sig
CHANGED
|
Binary file
|