diff --git a/README.md b/README.md index 543afdc..640195b 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/lib/hotwire/spark/default_options.rb b/lib/hotwire/spark/default_options.rb index 7701bd0..8190390 100644 --- a/lib/hotwire/spark/default_options.rb +++ b/lib/hotwire/spark/default_options.rb @@ -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 diff --git a/test/dummy/app/views/home/show.html.erb b/test/dummy/app/views/home/show.html.erb index 328fc73..5befd09 100644 --- a/test/dummy/app/views/home/show.html.erb +++ b/test/dummy/app/views/home/show.html.erb @@ -2,5 +2,6 @@
This is pretty cool, isn't it?
_REPLACE_HTML_
_REPLACE_
+<%= I18n.t(".hello") %>
<%= image_tag "green_rectangle.png", id: "image" %> diff --git a/test/yaml_html_reload_test.rb b/test/yaml_html_reload_test.rb new file mode 100644 index 0000000..918379c --- /dev/null +++ b/test/yaml_html_reload_test.rb @@ -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