adamh-html_namespacing 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +9 -0
- data/Rakefile +1 -1
- data/html_namespacing.gemspec +1 -1
- data/lib/html_namespacing/plugin/rails.rb +15 -2
- metadata +1 -1
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
data/html_namespacing.gemspec
CHANGED
@@ -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
|
-
|
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
|