Skip to content

Commit

Permalink
Allow locale changes to reload the page
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoroth committed Jan 10, 2025
1 parent 3161548 commit 220b7db
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 10 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ config.hotwire.spark.html_paths += %w[ lib ]

### Monitored paths

| Name | Description |
|-----------------------|---------------------------------------------------------------------------------------------------------------------------------------------------|
| `html_paths` | Paths where file changes trigger a content refresh. By default: `app/controllers`, `app/helpers`, `app/assets/images`, `app/models`, `app/views`. |
| `html_extensions` | The extensions to monitor for HTML content changes. By default: `rb`, `erb`, `png`, `jpg`, `jpeg`, `webp`, `svg`. |
| `css_paths` | Paths where file changes trigger a CSS refresh. By default: `app/assets/stylesheets` or `app/assets/builds` if exists. |
| `css_extensions` | The extensions to monitor for CSS changes. By default: `css`. |
| `stimulus_paths` | Paths where file changes trigger a Stimulus controller refresh. By default: `app/javascript/controllers`. |
| `stimulus_extensions` | The extensions to monitor for Stimulus changes. By default: `js`. |
| Name | Description |
|-----------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `html_paths` | Paths where file changes trigger a content refresh. By default: `app/controllers`, `app/helpers`, `app/assets/images`, `app/models`, `app/views`, `config/locales`. |
| `html_extensions` | The extensions to monitor for HTML content changes. By default: `rb`, `erb`, `png`, `jpg`, `jpeg`, `webp`, `svg`, `yaml`, `yml`. |
| `css_paths` | Paths where file changes trigger a CSS refresh. By default: `app/assets/stylesheets` or `app/assets/builds` if exists. |
| `css_extensions` | The extensions to monitor for CSS changes. By default: `css`. |
| `stimulus_paths` | Paths where file changes trigger a Stimulus controller refresh. By default: `app/javascript/controllers`. |
| `stimulus_extensions` | The extensions to monitor for Stimulus changes. By default: `js`. |

## License

Expand Down
4 changes: 2 additions & 2 deletions lib/hotwire/spark/default_options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ def base_options
enabled: Rails.env.development?,
css_paths: File.directory?("app/assets/builds") ? %w[ app/assets/builds ] : %w[ app/assets/stylesheets ],
css_extensions: %w[ css ],
html_paths: %w[ app/controllers app/helpers app/assets/images app/models app/views ],
html_extensions: %w[ rb erb png jpg jpeg webp svg ],
html_paths: %w[ app/controllers app/helpers app/assets/images app/models app/views config/locales ],
html_extensions: %w[ rb erb png jpg jpeg webp svg yaml yml ],
stimulus_paths: %w[ app/javascript/controllers ],
stimulus_extensions: %w[ js ],
html_reload_method: :morph
Expand Down
1 change: 1 addition & 0 deletions test/dummy/app/views/home/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
<p>This is pretty cool, isn't it?</p>
<p>_REPLACE_HTML_</p>
<p id="replace">_REPLACE_</p>
<p id="translation"><%= I18n.t(".hello") %></p>
<%= image_tag "green_rectangle.png", id: "image" %>
</div>
13 changes: 13 additions & 0 deletions test/yaml_html_reload_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
require "application_system_test_case"

class YamlHtmlReloadTest < ApplicationSystemTestCase
test "yaml changes reloads the page" do
visit root_path

assert_equal "Hello world", find("#translation").text

edit_file "config/locales/en.yml", replace: "Hello world", with: "Hello spark"

assert_equal "Hello spark", find("#translation").text
end
end

0 comments on commit 220b7db

Please sign in to comment.