minimal 0.0.19 → 0.0.20

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.textile CHANGED
@@ -1,4 +1,4 @@
1
- Minimal::Template is an experimental, minimalistic templating engine inspired by "Markaby":http://github.com/markaby/markaby & "Erector":http://erector.rubyforge.org but much smaller (~60 loc) and targeted at Rails 3.
1
+ Minimal::Template is an experimental, minimalistic templating engine inspired by "Markaby":http://github.com/markaby/markaby & "Erector":http://erector.rubyforge.org but much smaller (~55 loc) and targeted at Rails 3.
2
2
 
3
3
  <pre># views/foo/bar.rb
4
4
  module Foo
@@ -6,13 +6,13 @@ class Minimal::Template
6
6
  AUTO_BUFFER = %r(render|tag|error_message_|select|debug|_to|[^l]_for)
7
7
  TAG_NAMES = %w(abbr a body div em fieldset h1 h2 h3 h4 h5 h6 head html img input label li
8
8
  link ol option p pre script select span strong table thead tbody tfoot td title th tr ul)
9
- SKIP_IVARS = [:controller]
10
9
 
11
10
  module Base
12
11
  attr_accessor :view, :locals, :block
13
12
 
14
13
  def initialize(view = nil)
15
14
  @view, @locals, @_auto_buffer = view, {}, {}
15
+ view.assigns.each { |name, value| instance_variable_set(:"@#{name}", value) } if view
16
16
  end
17
17
 
18
18
  def _render(locals = nil, format = :html, &block)
@@ -24,12 +24,10 @@ class Minimal::Template
24
24
 
25
25
  TAG_NAMES.each do |name|
26
26
  define_method(name) { |*args, &block| content_tag(name, *args, &block) }
27
- # define_method("#{name}_for") { |*args, &block| content_tag_for(name, *args, &block) }
28
27
  end
29
28
 
30
29
  def <<(output)
31
- view.output_buffer << output
32
- view.output_buffer << "\n".html_safe
30
+ view.output_buffer << output << "\n".html_safe
33
31
  end
34
32
  alias :output :<<
35
33
 
@@ -41,15 +39,10 @@ class Minimal::Template
41
39
 
42
40
  def method_missing(method, *args, &block)
43
41
  return locals[method] if locals.key?(method)
44
- return view.instance_variable_get("@#{method}") if ivar?(method)
45
42
  return call_view(method, *args, &block) if view.respond_to?(method)
46
43
  super
47
44
  end
48
45
 
49
- def ivar?(method)
50
- !SKIP_IVARS.include?(method) && view.instance_variable_defined?("@#{method}") rescue false
51
- end
52
-
53
46
  def call_view(method, *args, &block)
54
47
  view.send(method, *args, &block).tap { |result| self << result if auto_buffer?(method) }
55
48
  end
@@ -1,3 +1,3 @@
1
1
  module Minimal
2
- VERSION = "0.0.19"
2
+ VERSION = "0.0.20"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minimal
3
3
  version: !ruby/object:Gem::Version
4
- hash: 57
4
+ hash: 55
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 19
10
- version: 0.0.19
9
+ - 20
10
+ version: 0.0.20
11
11
  platform: ruby
12
12
  authors:
13
13
  - Sven Fuchs
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-09-15 00:00:00 +02:00
18
+ date: 2010-09-29 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency