Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow locales changes to reload the page #67

Merged
merged 1 commit into from
Jan 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading