Merge pull request #39204 from prathamesh-sonpatki/template-annotation

Add the configuration option for annotating templates with file names to the generated app
This commit is contained in:
Rafael França 2020-05-19 19:11:31 -04:00 committed by GitHub
commit a80115b7c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 29 additions and 22 deletions

View File

@ -57,8 +57,8 @@ Rails.application.configure do
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
# Render template filenames as comments in HTML
# config.action_view.annotate_template_file_names = true
# Annotate rendered view with file names
# config.action_view.annotate_rendered_view_with_filenames = true
# Use an evented file watcher to asynchronously detect changes in source code,
# routes, locales, etc. This feature depends on the listen gem.

View File

@ -44,6 +44,6 @@ Rails.application.configure do
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
# Render template filenames as comments in HTML
# config.action_view.annotate_template_file_names = true
# Annotate rendered view with file names
# config.action_view.annotate_rendered_view_with_filenames = true
end

View File

@ -57,8 +57,8 @@ Rails.application.configure do
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
# Render template filenames as comments in HTML
# config.action_view.annotate_template_file_names = true
# Annotate rendered view with file names
# config.action_view.annotate_rendered_view_with_filenames = true
# Use an evented file watcher to asynchronously detect changes in source code,
# routes, locales, etc. This feature depends on the listen gem.

View File

@ -44,6 +44,6 @@ Rails.application.configure do
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
# Render template filenames as comments in HTML
# config.action_view.annotate_template_file_names = true
# Annotate rendered view with file names
# config.action_view.annotate_rendered_view_with_filenames = true
end

View File

@ -2,7 +2,7 @@
*Zach Kemp*
* `ActionView::Base.annotate_template_file_names` annotates HTML output with template file names.
* `ActionView::Base.annotate_rendered_view_with_filenames` annotates HTML output with template file names.
*Joel Hawksley*, *Aaron Patterson*

View File

@ -162,8 +162,8 @@ module ActionView #:nodoc:
# Specify whether submit_tag should automatically disable on click
cattr_accessor :automatically_disable_submit_tag, default: true
# Render template filenames as comments in HTML
cattr_accessor :annotate_template_file_names, default: false
# Annotate rendered view with file names
cattr_accessor :annotate_rendered_view_with_filenames, default: false
class_attribute :_routes
class_attribute :logger

View File

@ -79,7 +79,7 @@ module ActionView
private
def annotate?(template)
ActionView::Base.annotate_template_file_names && template.format == :html
ActionView::Base.annotate_rendered_view_with_filenames && template.format == :html
end
def valid_encoding(string, encoding)

View File

@ -1455,7 +1455,7 @@ class RenderTest < ActionController::TestCase
end
def test_template_annotations
ActionView::Base.annotate_template_file_names = true
ActionView::Base.annotate_rendered_view_with_filenames = true
get :greeting
@ -1469,22 +1469,22 @@ class RenderTest < ActionController::TestCase
assert_includes lines.last, "<!-- END"
assert_includes lines.last, "test/fixtures/actionpack/test/greeting.html.erb -->"
ensure
ActionView::Base.annotate_template_file_names = false
ActionView::Base.annotate_rendered_view_with_filenames = false
end
def test_template_annotations_do_not_render_for_non_html_format
ActionView::Base.annotate_template_file_names = true
ActionView::Base.annotate_rendered_view_with_filenames = true
get :render_with_explicit_template_with_locals
assert_not_includes @response.body, "BEGIN"
assert_equal @response.body.split("\n").length, 1
ensure
ActionView::Base.annotate_template_file_names = false
ActionView::Base.annotate_rendered_view_with_filenames = false
end
def test_line_offset_with_annotations_enabled
ActionView::Base.annotate_template_file_names = true
ActionView::Base.annotate_rendered_view_with_filenames = true
exc = assert_raises ActionView::Template::Error do
get :render_line_offset
@ -1494,6 +1494,6 @@ class RenderTest < ActionController::TestCase
assert_equal "1", $1,
"The line offset is wrong, perhaps the wrong exception has been raised, exception was: #{exc.inspect}"
ensure
ActionView::Base.annotate_template_file_names = false
ActionView::Base.annotate_rendered_view_with_filenames = false
end
end

View File

@ -46,8 +46,8 @@ Rails.application.configure do
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
# Render template filenames as comments in HTML
# config.action_view.annotate_template_file_names = true
# Annotate rendered view with file names
# config.action_view.annotate_rendered_view_with_filenames = true
# Use an evented file watcher to asynchronously detect changes in source code,
# routes, locales, etc. This feature depends on the listen gem.

View File

@ -36,6 +36,6 @@ Rails.application.configure do
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
# Render template filenames as comments in HTML
# config.action_view.annotate_template_file_names = true
# Annotate rendered view with file names
# config.action_view.annotate_rendered_view_with_filenames
end

View File

@ -668,6 +668,7 @@ Defaults to `'signed cookie'`.
* `config.action_view.default_enforce_utf8` determines whether forms are generated with a hidden tag that forces older versions of Internet Explorer to submit forms encoded in UTF-8. This defaults to `false`.
* `config.action_view.annotate_rendered_view_with_filenames` determines whether to annotate rendered view with template file names. This defaults to `false`.
### Configuring Action Mailbox

View File

@ -74,6 +74,9 @@ Rails.application.configure do
# Raises error for missing translations.
# config.action_view.raise_on_missing_translations = true
# Annotate rendered view with file names
# config.action_view.annotate_rendered_view_with_filenames = true
# Use an evented file watcher to asynchronously detect changes in source code,
# routes, locales, etc. This feature depends on the listen gem.
<%= '# ' unless depend_on_listen? %>config.file_watcher = ActiveSupport::EventedFileUpdateChecker

View File

@ -63,4 +63,7 @@ Rails.application.configure do
# Raises error for missing translations.
# config.action_view.raise_on_missing_translations = true
# Annotate rendered view with file names
# config.action_view.annotate_rendered_view_with_filenames = true
end