-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add custom resolver to prevent Rails from rendering Haml Coffee templ…
…ates for non-HTML formats. Fixes #80.
- Loading branch information
1 parent
c566a25
commit c8991d3
Showing
2 changed files
with
28 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
require "action_view" | ||
|
||
module HamlCoffeeAssets | ||
module ActionView | ||
# Custom resolver to prevent Haml Coffee templates from being rendered by | ||
# Rails for non-HTML formats, since a template name without a MIME type | ||
# in it would normally be a fallback for all formats. | ||
# | ||
class Resolver < ::ActionView::FileSystemResolver | ||
def find_templates(name, prefix, partial, details) | ||
if details[:formats].include?(:html) | ||
super | ||
else | ||
[] | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters