adamh-html_namespacing 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.rdoc CHANGED
@@ -110,6 +110,15 @@ default is:
110
110
 
111
111
  If the callback returns <tt>nil</tt>, HTML namespacing will not be applied.
112
112
 
113
+ <tt>:handle_exception_callback</tt>: Ruby lambda function which accepts
114
+ an <tt>Exception</tt>, an <tt>ActionView::Template</tt>, and an
115
+ <tt>ActionView::Base</tt>. The default behavior is:
116
+
117
+ lambda { |exception, template, view| raise(exception) }
118
+
119
+ If your <tt>:handle_exception_callback</tt> does not raise an exception,
120
+ the template will be rendered as if HtmlNamespacing were not installed.
121
+
113
122
  == Why?
114
123
 
115
124
  HTML namespacing gives huge benefits when writing CSS and JavaScript:
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  require 'rake'
3
3
  require 'echoe'
4
4
 
5
- Echoe.new('html_namespacing', '0.0.2') do |p|
5
+ Echoe.new('html_namespacing', '0.0.3') do |p|
6
6
  p.author = 'Adam Hooper'
7
7
  p.email = 'adam@adamhooper.com'
8
8
  p.summary = 'Automatic HTML namespacing'
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{html_namespacing}
5
- s.version = "0.0.2"
5
+ s.version = "0.0.3"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Adam Hooper"]
@@ -15,6 +15,14 @@ module HtmlNamespacing
15
15
  end
16
16
  end
17
17
 
18
+ def self.handle_exception(e, template, view)
19
+ if func = @options[:handle_exception_callback]
20
+ func.call(e, template, view)
21
+ else
22
+ raise(e)
23
+ end
24
+ end
25
+
18
26
  private
19
27
 
20
28
  def self.install_rails_2_3(options = {})
@@ -23,12 +31,17 @@ module HtmlNamespacing
23
31
  s = render_template_without_html_namespacing(*args)
24
32
 
25
33
  if format == 'html'
26
- HtmlNamespacing::add_namespace_to_html(s, html_namespace)
34
+ begin
35
+ HtmlNamespacing::add_namespace_to_html(s, html_namespace)
36
+ rescue ArgumentError => e
37
+ view = args.first
38
+ HtmlNamespacing::Plugin::Rails.handle_exception(e, self, view)
39
+ s # unless handle_exception() raised something
40
+ end
27
41
  else
28
42
  s
29
43
  end
30
44
  end
31
-
32
45
  alias_method_chain :render_template, :html_namespacing
33
46
 
34
47
  def html_namespace
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adamh-html_namespacing
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Hooper