Skip to content

Commit

Permalink
Allow custom template exclusion from BetterErb processing. Fix #1
Browse files Browse the repository at this point in the history
  • Loading branch information
Francois Chagnon committed Mar 23, 2017
1 parent 60bbdb1 commit a93ac11
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions lib/better_html.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ class Config
# name of all html attributes that may contain javascript
cattr_accessor :javascript_attribute_names
self.javascript_attribute_names = [/\Aon/i]

cattr_accessor :template_exclusion_filter_block

def self.template_exclusion_filter(&block)
self.template_exclusion_filter_block = block
end
end

def self.config
Expand Down
3 changes: 2 additions & 1 deletion lib/better_html/better_erb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ def generate(template)
# Always make sure we return a String in the default_internal
erb.encode!

klass = BetterHtml::BetterErb.content_types[exts]
excluded_template = !!BetterHtml::Config.template_exclusion_filter_block&.call(template.identifier)
klass = BetterHtml::BetterErb.content_types[exts] unless excluded_template
klass ||= self.class.erb_implementation

generator = klass.new(
Expand Down

0 comments on commit a93ac11

Please sign in to comment.