deface 1.8.1 → 1.8.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +7 -0
- data/.github/workflows/main.yml +45 -0
- data/Appraisals +18 -3
- data/CONTRIBUTING.md +12 -0
- data/README.markdown +89 -105
- data/bin/setup +8 -0
- data/deface.gemspec +8 -2
- data/gemfiles/rails_5.2.gemfile +2 -1
- data/gemfiles/rails_6.0.gemfile +2 -1
- data/gemfiles/rails_6.1.gemfile +2 -1
- data/gemfiles/rails_6_1.gemfile +6 -1
- data/lib/deface/version.rb +1 -1
- metadata +24 -7
- data/.travis.yml +0 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f95e0d9ff0d9928f8791253e4ce8a96e8c3dfda75505f1f6f9d96d5b50ee20cc
|
4
|
+
data.tar.gz: 5db5672c1fc4c8e43a591674a6d60950a6b70e48f54adbcb9d3f0a380ad2e039
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b36c2c608cc51a7975a97da0931e351be90dc4a19d4c51bc37d3f5fe6a0023ed31a6b67ed01d6b17105ded32edf6b1d6cfd1a1bd538471a52790fbb526f1cf6
|
7
|
+
data.tar.gz: 8cf7a37e8af2c13cfcbdeaf039434fd8736e777ec7fb2a2ceeb7186b0a49e4d931c14459e882d71d5d10b527ab523f9f1d6500f452c6acb2b5746b6c015aa99b
|
@@ -0,0 +1,45 @@
|
|
1
|
+
on:
|
2
|
+
- push
|
3
|
+
- pull_request
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
name: "ruby ${{ matrix.combo.ruby }} / ${{ matrix.combo.gemfile }}"
|
8
|
+
strategy:
|
9
|
+
matrix:
|
10
|
+
combo:
|
11
|
+
# TODO: re-enable commented combos and expand the matrix to Ruby 3.1 and Rails 7+
|
12
|
+
|
13
|
+
# - ruby: "3.0"
|
14
|
+
# gemfile: "rails_6_1"
|
15
|
+
# - ruby: "2.7"
|
16
|
+
# gemfile: "rails_6_1"
|
17
|
+
- ruby: "2.6"
|
18
|
+
gemfile: "rails_6_1"
|
19
|
+
- ruby: "2.5"
|
20
|
+
gemfile: "rails_6_1"
|
21
|
+
|
22
|
+
# - ruby: "2.7"
|
23
|
+
# gemfile: "rails_6_0"
|
24
|
+
- ruby: "2.6"
|
25
|
+
gemfile: "rails_6_0"
|
26
|
+
- ruby: "2.5"
|
27
|
+
gemfile: "rails_6_0"
|
28
|
+
|
29
|
+
- ruby: "2.5"
|
30
|
+
gemfile: "rails_5_2"
|
31
|
+
|
32
|
+
runs-on: ubuntu-latest
|
33
|
+
|
34
|
+
env:
|
35
|
+
GEMFILE_PATH: gemfiles/${{ matrix.combo.gemfile }}.gemfile
|
36
|
+
|
37
|
+
steps:
|
38
|
+
- uses: actions/checkout@v2
|
39
|
+
- uses: ruby/setup-ruby@v1
|
40
|
+
with:
|
41
|
+
ruby-version: ${{ matrix.combo.ruby }}
|
42
|
+
- name: Setup project
|
43
|
+
run: bin/setup
|
44
|
+
- name: Run test
|
45
|
+
run: "bundle exec rake"
|
data/Appraisals
CHANGED
@@ -1,11 +1,26 @@
|
|
1
1
|
appraise 'rails-5.2' do
|
2
|
-
|
2
|
+
%w[
|
3
|
+
actionview
|
4
|
+
railties
|
5
|
+
].each do |rails_gem|
|
6
|
+
gem rails_gem, '~> 5.2.0'
|
7
|
+
end
|
3
8
|
end
|
4
9
|
|
5
10
|
appraise 'rails-6.0' do
|
6
|
-
|
11
|
+
%w[
|
12
|
+
actionview
|
13
|
+
railties
|
14
|
+
].each do |rails_gem|
|
15
|
+
gem rails_gem, '~> 6.0.0'
|
16
|
+
end
|
7
17
|
end
|
8
18
|
|
9
19
|
appraise 'rails-6.1' do
|
10
|
-
|
20
|
+
%w[
|
21
|
+
actionview
|
22
|
+
railties
|
23
|
+
].each do |rails_gem|
|
24
|
+
gem rails_gem, '~> 6.1.0'
|
25
|
+
end
|
11
26
|
end
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# Contributing
|
2
|
+
|
3
|
+
## Setup you development environment
|
4
|
+
|
5
|
+
1. Clone the repo
|
6
|
+
2. Run `bin/setup` to install dependencies
|
7
|
+
3. Run `bin/sandbox` to (re)generate the sandbox application for local experiments
|
8
|
+
|
9
|
+
## To run specs locally on the matrix of supported versions
|
10
|
+
|
11
|
+
1. Run `bundle exec appraisal install`
|
12
|
+
2. Run `bundle exec appraisal rake`
|
data/README.markdown
CHANGED
@@ -1,41 +1,13 @@
|
|
1
|
-
|
2
|
-
<a href="http://secure.travis-ci.org/spree/deface">
|
3
|
-
<img src="https://secure.travis-ci.org/spree/deface.svg?branch=master">
|
4
|
-
</a>
|
5
|
-
</p>
|
1
|
+
# Deface
|
6
2
|
|
7
|
-
|
8
|
-
======
|
3
|
+
[![Travis build](https://secure.travis-ci.org/spree/deface.svg?branch=master)](https://travis-ci.com/github/spree/deface)
|
9
4
|
|
10
5
|
Deface is a library that allows you to customize HTML (ERB, Haml and Slim) views in a Rails application without editing the underlying view.
|
11
6
|
|
12
7
|
It allows you to easily target html & erb elements as the hooks for customization using CSS selectors as supported by Nokogiri.
|
13
8
|
|
14
9
|
|
15
|
-
|
16
|
-
-------------------------
|
17
|
-
|
18
|
-
If you are updating from 0.9.x to 1.0.0 or higher, there's a major internal change you should be aware of.
|
19
|
-
|
20
|
-
Previously, erb blocks (i.e. <%= some_method %>) were converted as:
|
21
|
-
|
22
|
-
```html
|
23
|
-
<code erb-loud> some_method </code>
|
24
|
-
```
|
25
|
-
They are now converted to:
|
26
|
-
|
27
|
-
```html
|
28
|
-
<erb loud> some_method </erb>
|
29
|
-
```
|
30
|
-
|
31
|
-
This change will affect any Override that uses a selector that matches on `code` or `code[erb-loud]` or `code[erb-silent]` etc, they should be updated to `erb`, `erb[loud]` or `erb[silent]`, etc.
|
32
|
-
|
33
|
-
Note: HAML & SLIM are preconverted to ERB before Deface parsers them, so the same conversions are happening there.
|
34
|
-
|
35
|
-
See the [Implementation](#implementation) section below for more details.
|
36
|
-
|
37
|
-
Usage
|
38
|
-
-----
|
10
|
+
## Usage
|
39
11
|
|
40
12
|
There are two ways of using Deface:
|
41
13
|
|
@@ -46,10 +18,9 @@ Both methods are interoperable, so you can use a mix, and redefine overrides def
|
|
46
18
|
|
47
19
|
|
48
20
|
|
49
|
-
Using Deface::Override
|
50
|
-
----------------------
|
21
|
+
## Using Deface::Override
|
51
22
|
|
52
|
-
A new instance of the Deface::Override class is initialized for each customization you wish to define. When initializing a new override you must supply only one Target, Action & Source parameter and any number of Optional parameters.
|
23
|
+
A new instance of the Deface::Override class is initialized for each customization you wish to define. When initializing a new override you must supply only one Target, Action & Source parameter and any number of Optional parameters.
|
53
24
|
|
54
25
|
**Note:** the source parameter is not required when the ````:remove, :set_attributes, :add_to_attributes, :remove_from_attributes```` actions are specified.
|
55
26
|
|
@@ -59,77 +30,77 @@ You should save your overrides in the ````app/overrides````, normally one overri
|
|
59
30
|
|
60
31
|
### Target
|
61
32
|
|
62
|
-
*
|
33
|
+
* `:virtual_path` - The template / partial / layout where the override should take effect eg: *"shared/_person"*, *"admin/posts/new"* this will apply to all controller actions that use the specified template.
|
63
34
|
|
64
35
|
### Action
|
65
36
|
|
66
|
-
*
|
37
|
+
* `:remove` - Removes all elements that match the supplied selector
|
67
38
|
|
68
|
-
*
|
39
|
+
* `:replace` - Replaces all elements that match the supplied selector
|
69
40
|
|
70
|
-
*
|
41
|
+
* `:replace_contents` - Replaces the contents of all elements that match the supplied selector
|
71
42
|
|
72
|
-
*
|
43
|
+
* `:surround` - Surrounds all elements that match the supplied selector, expects replacement markup to contain <%= render_original %> placeholder
|
73
44
|
|
74
|
-
*
|
45
|
+
* `:surround_contents` - Surrounds the contents of all elements that match the supplied selector, expects replacement markup to contain <%= render_original %> placeholder
|
75
46
|
|
76
|
-
*
|
47
|
+
* `:insert_after` - Inserts after all elements that match the supplied selector
|
77
48
|
|
78
|
-
*
|
49
|
+
* `:insert_before` - Inserts before all elements that match the supplied selector
|
79
50
|
|
80
|
-
*
|
51
|
+
* `:insert_top` - Inserts inside all elements that match the supplied selector, as the first child.
|
81
52
|
|
82
|
-
*
|
53
|
+
* `:insert_bottom` - Inserts inside all elements that match the supplied selector, as the last child.
|
83
54
|
|
84
|
-
*
|
55
|
+
* `:set_attributes` - Sets attributes on all elements that match the supplied selector, replacing existing attribute value if present or adding if not. Expects :attributes option to be passed.
|
85
56
|
|
86
|
-
*
|
57
|
+
* `:add_to_attributes` - Appends value to attributes on all elements that match the supplied selector, adds attribute if not present. Expects :attributes option to be passed.
|
87
58
|
|
88
|
-
*
|
59
|
+
* `:remove_from_attributes` - Removes value from attributes on all elements that match the supplied selector. Expects :attributes option to be passed.
|
89
60
|
|
90
61
|
### Source
|
91
62
|
|
92
|
-
*
|
63
|
+
* `:text` - String containing markup
|
93
64
|
|
94
|
-
*
|
65
|
+
* `:partial` - Relative path to a partial
|
95
66
|
|
96
|
-
*
|
67
|
+
* `:template` - Relative path to a template
|
97
68
|
|
98
|
-
*
|
99
|
-
*
|
100
|
-
*
|
69
|
+
* `:cut` - Cuts (i.e. copies and removes) an element or a range of elements from the current template as the source, using css selector(s). Supports two versions:
|
70
|
+
* `selector` - A single string css selector (first match is used).
|
71
|
+
* `{:start => 'selector_a', :end => 'selector_b'}` - select a range of elements using :start and :end css selectors. The end element must be a sibling of the first/starting element.
|
101
72
|
|
102
|
-
*
|
103
|
-
*
|
104
|
-
*
|
73
|
+
* `:copy` - Copies an element or a range of elements from the current template as the source, using css selector(s). Supports two versions:
|
74
|
+
* `selector` - A single string css selector (first match is used).
|
75
|
+
* `{:start => 'selector_a', :end => 'selector_b'}` - select a range of elements using :start and :end css selectors. The end element must be a sibling of the first/starting element.
|
105
76
|
|
106
77
|
### Optional
|
107
78
|
|
108
|
-
*
|
79
|
+
* `:name` - Unique name for override so it can be identified and modified later. This needs to be unique within the same `:virtual_path`
|
109
80
|
|
110
|
-
*
|
81
|
+
* `:disabled` - When set to true the override will not be applied.
|
111
82
|
|
112
|
-
*
|
83
|
+
* `:original` - Either a string containing the original markup that is being overridden, or a string that is the SHA1 digest of the original markup. If supplied Deface will log when the original markup changes, which helps highlight overrides that need attention when upgrading versions of the source application. Only really warranted for :replace overrides. NB: All whitespace is stripped before comparison. To generate the SHA1 digest do: `Digest::SHA1.hexdigest(original_markup_string.gsub(/\s/, ''))`
|
113
84
|
|
114
|
-
*
|
85
|
+
* `:closing_selector` - A second css selector targeting an end element, allowing you to select a range of elements to apply an action against. The :closing_selector only supports the :replace, :remove and :replace_contents actions, and the end element must be a sibling of the first/starting element. Note the CSS general sibling selector (~) is used to match the first element after the opening selector (see below for an example).
|
115
86
|
|
116
|
-
*
|
117
|
-
*
|
118
|
-
*
|
119
|
-
same virtual_path, the current override will be appplied before
|
87
|
+
* `:sequence` - Used to order the application of an override for a specific virtual path, helpful when an override depends on another override being applied first, supports:
|
88
|
+
* `:sequence => n` - where n is a positive or negative integer (lower numbers get applied first, default 100).
|
89
|
+
* `:sequence => {:before => "*override_name*"}` - where "*override_name*" is the name of an override defined for the
|
90
|
+
same virtual_path, the current override will be appplied before
|
120
91
|
the named override passed.
|
121
|
-
*
|
92
|
+
* `:sequence => {:after => "*override_name*"}` - the current override will be applied after the named override passed.
|
122
93
|
|
123
|
-
*
|
94
|
+
* `:attributes` - A hash containing all the attributes to be set on the matched elements, eg: :attributes => {:class => "green", :title => "some string"}
|
124
95
|
|
125
96
|
### Examples
|
126
97
|
|
127
98
|
Replaces all instances of `h1` in the `posts/_form.html.erb` partial with `<h1>New Post</h1>`
|
128
99
|
|
129
100
|
```ruby
|
130
|
-
Deface::Override.new(:virtual_path => "posts/_form",
|
131
|
-
:name => "example-1",
|
132
|
-
:replace => "h1",
|
101
|
+
Deface::Override.new(:virtual_path => "posts/_form",
|
102
|
+
:name => "example-1",
|
103
|
+
:replace => "h1",
|
133
104
|
:text => "<h1>New Post</h1>")
|
134
105
|
```
|
135
106
|
|
@@ -146,8 +117,8 @@ end
|
|
146
117
|
Inserts `<%= link_to "List Comments", comments_url(post) %>` before all instances of `p` with css class `comment` in `posts/index.html.erb`
|
147
118
|
|
148
119
|
```ruby
|
149
|
-
Deface::Override.new(:virtual_path => "posts/index",
|
150
|
-
:name => "example-2",
|
120
|
+
Deface::Override.new(:virtual_path => "posts/index",
|
121
|
+
:name => "example-2",
|
151
122
|
:insert_before => "p.comment",
|
152
123
|
:text => "<%= link_to 'List Comments', comments_url(post) %>")
|
153
124
|
```
|
@@ -155,17 +126,17 @@ Deface::Override.new(:virtual_path => "posts/index",
|
|
155
126
|
Inserts the contents of `shared/_comment.html.erb` after all instances of `div` with an id of `comment_21` in `posts/show.html.erb`
|
156
127
|
|
157
128
|
```ruby
|
158
|
-
Deface::Override.new(:virtual_path => "posts/show",
|
129
|
+
Deface::Override.new(:virtual_path => "posts/show",
|
159
130
|
:name => "example-3",
|
160
|
-
:insert_after => "div#comment_21",
|
131
|
+
:insert_after => "div#comment_21",
|
161
132
|
:partial => "shared/comment")
|
162
133
|
```
|
163
134
|
|
164
135
|
Removes any ERB block containing the string `helper_method` in the `posts/new.html.erb` template, will also log if markup being removed does not exactly match `<%= helper_method %>`
|
165
136
|
|
166
137
|
```ruby
|
167
|
-
Deface::Override.new(:virtual_path => "posts/new",
|
168
|
-
:name => "example-4",
|
138
|
+
Deface::Override.new(:virtual_path => "posts/new",
|
139
|
+
:name => "example-4",
|
169
140
|
:remove => "erb[loud]:contains('helper_method')",
|
170
141
|
:original => "<%= helper_method %>")
|
171
142
|
```
|
@@ -173,13 +144,13 @@ Deface::Override.new(:virtual_path => "posts/new",
|
|
173
144
|
Wraps the `div` with id of `products` in ruby if statement, the <%= render_original %> in the `text` indicates where the matching content should be re-included.
|
174
145
|
|
175
146
|
```ruby
|
176
|
-
Deface::Override.new(:virtual_path => "posts/new",
|
177
|
-
:name => "example-5",
|
147
|
+
Deface::Override.new(:virtual_path => "posts/new",
|
148
|
+
:name => "example-5",
|
178
149
|
:surround => "div#products",
|
179
150
|
:text => "<% if @product.present? %><%= render_original %><% end %>")
|
180
151
|
```
|
181
152
|
|
182
|
-
Sets (or adds if not present) the `class` and `title` attributes to all instances of `a` with an id of `link` in `posts/index.html.erb`
|
153
|
+
Sets (or adds if not present) the `class` and `title` attributes to all instances of `a` with an id of `link` in `posts/index.html.erb`
|
183
154
|
|
184
155
|
```ruby
|
185
156
|
Deface::Override.new(:virtual_path => 'posts/index',
|
@@ -203,7 +174,7 @@ Deface scopes overrides by virtual_path (or partial / template file), that means
|
|
203
174
|
|
204
175
|
### Redefining Overrides
|
205
176
|
|
206
|
-
You can redefine an existing override by simply declaring a new override with the same
|
177
|
+
You can redefine an existing override by simply declaring a new override with the same `:virtual_path`, `:name` and [action](#action) that was originally used.
|
207
178
|
You do not need to resupply all the values originally used, just the ones you want to change:
|
208
179
|
|
209
180
|
```ruby
|
@@ -231,8 +202,7 @@ This can also be activated globally for all DSL overrides in your app's `applica
|
|
231
202
|
config.deface.namespaced = true # default is false
|
232
203
|
```
|
233
204
|
|
234
|
-
Using the Deface DSL (.deface files)
|
235
|
-
------------------------------------
|
205
|
+
## Using the Deface DSL (.deface files)
|
236
206
|
|
237
207
|
Instead of defining Deface::Override instances directly, you can alternatively add `.deface` files to the `app/overrides` folder and Deface will automatically pick them up.
|
238
208
|
The path of each override should match the path of the view template you want to modify, say for example if you have a template at:
|
@@ -267,7 +237,7 @@ and including haml source:
|
|
267
237
|
You can include all the additional options you can normally use when defining a Deface::Override manually, a more complex example:
|
268
238
|
|
269
239
|
```html
|
270
|
-
<!-- replace_contents 'h1' closing_selector 'div#intro'
|
240
|
+
<!-- replace_contents 'h1' closing_selector 'div#intro'
|
271
241
|
sequence :before => 'my_other_override'
|
272
242
|
disabled -->
|
273
243
|
<p>This is a complicated example</p>
|
@@ -290,21 +260,22 @@ or
|
|
290
260
|
|
291
261
|
#### Namespacing
|
292
262
|
|
293
|
-
When using the DSL, overrides automatically take their name from the filename of the file in which they are defined
|
294
|
-
(ie `my_override.html.erb.deface` becomes `my_override`) so overrides with the same filename will replace each other,
|
263
|
+
When using the DSL, overrides automatically take their name from the filename of the file in which they are defined
|
264
|
+
(ie `my_override.html.erb.deface` becomes `my_override`) so overrides with the same filename will replace each other,
|
295
265
|
even if they are defined in separate engines. If you want to avoid this, you can use the `namespaced` option :
|
296
266
|
|
297
267
|
```erb
|
298
268
|
<!-- insert_bottom 'head' namespaced -->
|
299
269
|
```
|
270
|
+
|
300
271
|
or activate it globally for all DSL overrides in your app's `application.rb` file:
|
301
272
|
|
302
273
|
```ruby
|
303
274
|
config.deface.namespaced = true # default is false
|
304
275
|
```
|
305
276
|
|
306
|
-
Each override will then have its name namespaced to the engine in which it was defined
|
307
|
-
(ie `my_override.html.erb.deface` defined in `MyEngine` becomes `my_engine_my_override`),
|
277
|
+
Each override will then have its name namespaced to the engine in which it was defined
|
278
|
+
(ie `my_override.html.erb.deface` defined in `MyEngine` becomes `my_engine_my_override`),
|
308
279
|
allowing overrides in different engines with identical filenames to co-exist.
|
309
280
|
|
310
281
|
### DSL usage for overrides that do not include markup
|
@@ -323,29 +294,27 @@ attributes :alt => 'Click here to search'
|
|
323
294
|
```
|
324
295
|
|
325
296
|
|
326
|
-
Rake Tasks
|
327
|
-
----------
|
297
|
+
## Rake Tasks
|
328
298
|
|
329
299
|
Deface includes a couple of rake tasks that can be helpful when defining or debugging overrides.
|
330
300
|
|
331
|
-
|
301
|
+
`rake deface:get_result` - Will list the original contents of a partial or template, the overrides that have been defined for a that file, and the resulting markup. *get_result* takes a single argument which is the virtual path of the template / partial:
|
332
302
|
|
333
303
|
rake deface:get_result[shared/_head]
|
334
304
|
|
335
305
|
rake deface:get_result['admin/products/index']
|
336
306
|
|
337
|
-
|
307
|
+
`rake deface:test_selector` - Applies a given CSS selector against a partial or template and outputs the markup for each match (if any). *test_selector* requires two arguments, the first is the virtual_path for the partial / template, the second is the CSS selector to apply:
|
338
308
|
|
339
309
|
rake deface:test_selector[shared/_head,title]
|
340
310
|
|
341
311
|
rake deface:test_selector['admin/products/index','div.toolbar']
|
342
312
|
|
343
|
-
|
313
|
+
`rake deface:precompile` - Generates compiled views that contain all overrides applied. See `Production & Precompiling` section below for more.
|
344
314
|
|
345
315
|
rake deface:precompile
|
346
316
|
|
347
|
-
Production & Precompiling
|
348
|
-
-------------------------
|
317
|
+
## Production & Precompiling
|
349
318
|
|
350
319
|
Deface now supports precompiling where all overrides are loaded and applied to the original views and the resulting templates are then saved to your application's `app/compiled_views` directory. To precompile run:
|
351
320
|
|
@@ -380,19 +349,34 @@ end
|
|
380
349
|
after 'deploy:updated', 'deface:precompile'
|
381
350
|
```
|
382
351
|
|
352
|
+
## Upgrading from 0.9 to 1.0
|
353
|
+
|
354
|
+
If you are updating from 0.9.x to 1.0.0 or higher, there's a major internal change you should be aware of.
|
355
|
+
|
356
|
+
Previously, erb blocks (i.e. <%= some_method %>) were converted as:
|
357
|
+
|
358
|
+
```html
|
359
|
+
<code erb-loud> some_method </code>
|
360
|
+
```
|
361
|
+
They are now converted to:
|
362
|
+
|
363
|
+
```html
|
364
|
+
<erb loud> some_method </erb>
|
365
|
+
```
|
366
|
+
|
367
|
+
This change will affect any Override that uses a selector that matches on `code` or `code[erb-loud]` or `code[erb-silent]` etc, they should be updated to `erb`, `erb[loud]` or `erb[silent]`, etc.
|
383
368
|
|
384
|
-
|
385
|
-
|
386
|
-
|
369
|
+
Note: HAML & SLIM are preconverted to ERB before Deface parsers them, so the same conversions are happening there.
|
370
|
+
|
371
|
+
See the [Implementation](#implementation) section below for more details.
|
387
372
|
|
388
373
|
|
389
|
-
Implementation
|
390
|
-
==============
|
374
|
+
# Implementation
|
391
375
|
|
392
|
-
Deface temporarily converts ERB files into a pseudo HTML markup that can be parsed and
|
376
|
+
Deface temporarily converts ERB files into a pseudo HTML markup that can be parsed and queried by Nokogiri, using the following approach:
|
393
377
|
|
394
378
|
```erb
|
395
|
-
<%= some ruby code %>
|
379
|
+
<%= some ruby code %>
|
396
380
|
```
|
397
381
|
|
398
382
|
becomes:
|
@@ -401,8 +385,8 @@ becomes:
|
|
401
385
|
<erb loud> some ruby code </erb>
|
402
386
|
```
|
403
387
|
|
404
|
-
and
|
405
|
-
|
388
|
+
and
|
389
|
+
|
406
390
|
```erb
|
407
391
|
<% other ruby code %>
|
408
392
|
```
|
@@ -418,7 +402,7 @@ ERB that is contained inside a HTML tag definition is converted slightly differe
|
|
418
402
|
```erb
|
419
403
|
<p id="<%= dom_id @product %>" <%= "style='display:block';" %>>
|
420
404
|
```
|
421
|
-
|
405
|
+
|
422
406
|
becomes:
|
423
407
|
|
424
408
|
```html
|
@@ -428,8 +412,8 @@ becomes:
|
|
428
412
|
Deface overrides have full access to all variables accessible to the view being customized.
|
429
413
|
|
430
414
|
|
431
|
-
Caveats
|
432
|
-
|
415
|
+
# Caveats
|
416
|
+
|
433
417
|
Deface uses the amazing Nokogiri library (and in turn libxml) for parsing HTML / view files, in some circumstances either Deface's own pre-parser or libxml's will fail to correctly parse a template. You can avoid such issues by ensuring your templates contain valid HTML. Some other caveats include:
|
434
418
|
|
435
419
|
1. Ensure that your layout views include doctype, html, head and body tags in a single file, as Nokogiri will create such elements if it detects any of these tags have been incorrectly nested.
|
data/bin/setup
ADDED
data/deface.gemspec
CHANGED
@@ -30,7 +30,13 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.extra_rdoc_files = ["README.markdown"]
|
31
31
|
|
32
32
|
spec.add_dependency('nokogiri', '>= 1.6')
|
33
|
-
|
33
|
+
|
34
|
+
%w[
|
35
|
+
actionview
|
36
|
+
railties
|
37
|
+
].each do |rails_gem|
|
38
|
+
spec.add_dependency(rails_gem, '>= 5.2')
|
39
|
+
end
|
34
40
|
spec.add_dependency('rainbow', '>= 2.1.0')
|
35
41
|
spec.add_dependency('polyglot')
|
36
42
|
|
@@ -39,7 +45,7 @@ Gem::Specification.new do |spec|
|
|
39
45
|
spec.add_development_dependency('gem-release')
|
40
46
|
spec.add_development_dependency('rspec', '>= 3.1.0')
|
41
47
|
spec.add_development_dependency('haml', ['>= 4.0', '< 6'])
|
42
|
-
spec.add_development_dependency('slim', '~>
|
48
|
+
spec.add_development_dependency('slim', '~> 4.1')
|
43
49
|
spec.add_development_dependency('simplecov', '>= 0.6.4')
|
44
50
|
spec.add_development_dependency('generator_spec', '~> 0.8')
|
45
51
|
spec.add_development_dependency('pry')
|
data/gemfiles/rails_5.2.gemfile
CHANGED
data/gemfiles/rails_6.0.gemfile
CHANGED
data/gemfiles/rails_6.1.gemfile
CHANGED
data/gemfiles/rails_6_1.gemfile
CHANGED
data/lib/deface/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: deface
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.8.
|
4
|
+
version: 1.8.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian D Quinn
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -25,7 +25,21 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.6'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: actionview
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '5.2'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '5.2'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: railties
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
45
|
- - ">="
|
@@ -148,14 +162,14 @@ dependencies:
|
|
148
162
|
requirements:
|
149
163
|
- - "~>"
|
150
164
|
- !ruby/object:Gem::Version
|
151
|
-
version: '
|
165
|
+
version: '4.1'
|
152
166
|
type: :development
|
153
167
|
prerelease: false
|
154
168
|
version_requirements: !ruby/object:Gem::Requirement
|
155
169
|
requirements:
|
156
170
|
- - "~>"
|
157
171
|
- !ruby/object:Gem::Version
|
158
|
-
version: '
|
172
|
+
version: '4.1'
|
159
173
|
- !ruby/object:Gem::Dependency
|
160
174
|
name: simplecov
|
161
175
|
requirement: !ruby/object:Gem::Requirement
|
@@ -206,11 +220,13 @@ extensions: []
|
|
206
220
|
extra_rdoc_files:
|
207
221
|
- README.markdown
|
208
222
|
files:
|
223
|
+
- ".github/dependabot.yml"
|
224
|
+
- ".github/workflows/main.yml"
|
209
225
|
- ".gitignore"
|
210
226
|
- ".rspec"
|
211
|
-
- ".travis.yml"
|
212
227
|
- Appraisals
|
213
228
|
- CHANGELOG.markdown
|
229
|
+
- CONTRIBUTING.md
|
214
230
|
- Gemfile
|
215
231
|
- MIT-LICENSE
|
216
232
|
- README.markdown
|
@@ -220,6 +236,7 @@ files:
|
|
220
236
|
- bin/rails-sandbox
|
221
237
|
- bin/sandbox
|
222
238
|
- bin/sandbox-setup
|
239
|
+
- bin/setup
|
223
240
|
- deface.gemspec
|
224
241
|
- gemfiles/rails_5.2.gemfile
|
225
242
|
- gemfiles/rails_6.0.gemfile
|
@@ -341,7 +358,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
341
358
|
- !ruby/object:Gem::Version
|
342
359
|
version: '0'
|
343
360
|
requirements: []
|
344
|
-
rubygems_version: 3.
|
361
|
+
rubygems_version: 3.2.32
|
345
362
|
signing_key:
|
346
363
|
specification_version: 4
|
347
364
|
summary: Deface is a library that allows you to customize ERB, Haml and Slim views
|
data/.travis.yml
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
script: "bundle exec rake"
|
2
|
-
|
3
|
-
cache:
|
4
|
-
bundler: true
|
5
|
-
|
6
|
-
rvm:
|
7
|
-
- 2.5.8
|
8
|
-
- 2.6.6
|
9
|
-
- 2.7.2
|
10
|
-
- 3.0.0
|
11
|
-
|
12
|
-
gemfile:
|
13
|
-
- gemfiles/rails_5.2.gemfile
|
14
|
-
- gemfiles/rails_6.0.gemfile
|
15
|
-
- gemfiles/rails_6_1.gemfile
|
16
|
-
|
17
|
-
matrix:
|
18
|
-
exclude:
|
19
|
-
- rvm: 2.6.6
|
20
|
-
gemfile: gemfiles/rails_5.2.gemfile
|
21
|
-
- rvm: 2.7.2
|
22
|
-
gemfile: gemfiles/rails_5.2.gemfile
|
23
|
-
- rvm: 3.0.0
|
24
|
-
gemfile: gemfiles/rails_5.2.gemfile
|
25
|
-
- rvm: 3.0.0
|
26
|
-
gemfile: gemfiles/rails_6.0.gemfile
|