-
-
Notifications
You must be signed in to change notification settings - Fork 21
Don't compile external templates #94
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -365,4 +365,25 @@ def @view_context.ui_badge(count, **_options) | |
|
|
||
| assert_compiled_snapshot(template) | ||
| end | ||
|
|
||
| test "does not process templates that are not local" do | ||
| ReActionView.config.intercept_erb = true | ||
| Rails.stubs(:root).returns("/local/template") | ||
|
|
||
| template = %(<p><h2>I am invalid</h2></p>) | ||
| template_obj = ActionView::Template.new( | ||
| template, | ||
| "test_template", | ||
| ReActionView::Template::Handlers::ERB, | ||
| virtual_path: "test", | ||
| format: :html, | ||
| locals: [] | ||
| ) | ||
|
|
||
| compiled_source = template_obj.handler.call(template_obj, template) | ||
| result = @view_context.instance_eval(compiled_source).to_s | ||
|
|
||
| normalized_result = result.gsub(/>\s+</, "><").gsub(/\s+/, " ").strip | ||
| assert_equal "<p><h2>I am invalid</h2></p>", normalized_result | ||
|
Comment on lines
+383
to
+387
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test pattern follows your others, but, much to my surprise, something in this setup doesn't raise an error when I encounter an erroneous template. This frustrated my abilities to implement logging. We know real world usage raises per the original issue. Is there something askew with the test setup? |
||
| end | ||
| end | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Short of exposing this as a class method on the Herb handler, it felt like this duplication was either warranted, so we should consider a TemplateUtilities module that we can mix in. Thoughts?