minimal 0.0.6 → 0.0.7
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/lib/minimal/template/handler.rb +1 -1
- data/lib/minimal/template.rb +11 -8
- data/lib/minimal/version.rb +1 -1
- metadata +2 -2
|
@@ -3,9 +3,9 @@ class Minimal::Template
|
|
|
3
3
|
include ActionView::Template::Handlers::Compilable
|
|
4
4
|
|
|
5
5
|
def compile(template)
|
|
6
|
+
require_dependency template.identifier
|
|
6
7
|
<<-code
|
|
7
8
|
@output_buffer = ActiveSupport::SafeBuffer.new
|
|
8
|
-
require_dependency "#{template.identifier}"
|
|
9
9
|
#{template_class_name(template.identifier)}.new(self)._render(local_assigns)
|
|
10
10
|
code
|
|
11
11
|
end
|
data/lib/minimal/template.rb
CHANGED
|
@@ -8,10 +8,10 @@ class Minimal::Template
|
|
|
8
8
|
link ol option p pre script select span strong table thead tbody tfoot td th tr ul)
|
|
9
9
|
|
|
10
10
|
module Base
|
|
11
|
-
|
|
11
|
+
attr_accessor :view, :locals
|
|
12
12
|
|
|
13
13
|
def initialize(view = nil)
|
|
14
|
-
@view, @
|
|
14
|
+
@view, @locals, @_buffer = view, {}, {}
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
def _render(locals = nil)
|
|
@@ -26,24 +26,27 @@ class Minimal::Template
|
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
def <<(output)
|
|
29
|
-
view.output_buffer << output
|
|
29
|
+
view.output_buffer << output.to_s
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
def respond_to?(method)
|
|
33
|
-
locals.key?(method) || view.instance_variable_defined?("@#{method}")
|
|
33
|
+
view.respond_to?(method) || locals.key?(method) || view.instance_variable_defined?("@#{method}")
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
protected
|
|
37
37
|
|
|
38
38
|
def method_missing(method, *args, &block)
|
|
39
|
-
|
|
39
|
+
view.respond_to?(method) ? call_view(method, *args, &block) :
|
|
40
40
|
view.instance_variable_defined?("@#{method}") ? view.instance_variable_get("@#{method}") :
|
|
41
|
-
|
|
41
|
+
locals.key?(method) ? locals[method] : super
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
def call_view(method, *args, &block)
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
view.send(method, *args, &block).tap { |result| self << result if auto_buffer?(method) }
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def auto_buffer?(method)
|
|
49
|
+
@_buffer.key?(method) ? @_buffer[method] : @_buffer[method] = AUTO_BUFFER =~ method.to_s
|
|
47
50
|
end
|
|
48
51
|
end
|
|
49
52
|
include Base
|
data/lib/minimal/version.rb
CHANGED