minimal 0.0.1 → 0.0.2

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.
@@ -5,7 +5,7 @@ class Minimal::Template
5
5
  include ActionView::Template::Handlers::Compilable
6
6
 
7
7
  def compile(template)
8
- require template.identifier
8
+ require_dependency template.identifier
9
9
  klass = template.identifier =~ %r(views/(.*).rb) && $1.camelize
10
10
  "@output_buffer = ActiveSupport::SafeBuffer.new;#{klass}.new(self)._render(local_assigns)"
11
11
  end
@@ -14,14 +14,14 @@ class Minimal::Template
14
14
  AUTO_BUFFER = %r(render|tag|error_message_|select|debug|_to|_for)
15
15
  NO_AUTO_BUFFER = %r(form_tag|form_for)
16
16
 
17
- TAG_NAMES = %w(a body div em fieldset form h1 h2 h3 h4 head html img input
18
- label li link ol option p pre script select span strong table td th tr ul)
17
+ TAG_NAMES = %w(a body div em fieldset h1 h2 h3 h4 head html img input label li
18
+ link ol option p pre script select span strong table thead tbody tfoot td th tr ul)
19
19
 
20
20
  module Base
21
21
  attr_reader :view, :buffers, :locals
22
22
 
23
23
  def initialize(view = nil)
24
- @view, @buffers = view, []
24
+ @view, @buffers, @locals = view, [], {}
25
25
  end
26
26
 
27
27
  def _render(locals = nil)
@@ -32,6 +32,7 @@ class Minimal::Template
32
32
 
33
33
  TAG_NAMES.each do |name|
34
34
  define_method(name) { |*args, &block| content_tag(name, *args, &block) }
35
+ define_method("#{name}_for") { |*args, &block| content_tag_for(name, *args, &block) }
35
36
  end
36
37
 
37
38
  def <<(output)
@@ -47,7 +48,7 @@ class Minimal::Template
47
48
  end
48
49
 
49
50
  def call_view(method, *args, &block)
50
- block = lambda { |*args| self << view.with_output_buffer { yield(*args) } } if block
51
+ block = lambda { |*a| self << view.with_output_buffer { yield(*a) } } if block
51
52
  view.send(method, *args, &block).tap { |result| self << result if auto_buffer?(method) }
52
53
  end
53
54
 
@@ -56,4 +57,4 @@ class Minimal::Template
56
57
  end
57
58
  end
58
59
  include Base
59
- end
60
+ end
@@ -1,3 +1,3 @@
1
1
  module Minimal
2
- VERSION = "0.0.1"
3
- end
2
+ VERSION = "0.0.2"
3
+ end
@@ -61,6 +61,12 @@ class TemplateTest < Test::Unit::TestCase
61
61
  assert_equal html, view.output_buffer
62
62
  end
63
63
 
64
+ # test "does not buffer but return a helper's result when :capture => true was passed'" do
65
+ # result = template.a('foo', :href => '#', :capture => true)
66
+ # assert_equal '<a href="#">foo</a>', result
67
+ # assert_equal '', view.output_buffer
68
+ # end
69
+
64
70
  test "simple render with local assigns" do
65
71
  html = '<html><head></head><body><h1>plain</h1><p>local</p><div><div>nested</div></div></body></html>'
66
72
  assert_equal html, view.render(:file => 'foo/simple', :locals => { :local => 'local' })
@@ -108,4 +114,4 @@ class TemplateTest < Test::Unit::TestCase
108
114
  html
109
115
  assert_equal html, view.render(:file => 'foo/misc_helpers').gsub("\n", '')
110
116
  end
111
- end
117
+ end
data/test/test_helper.rb CHANGED
@@ -7,6 +7,8 @@ require 'minimal'
7
7
  require 'action_controller'
8
8
  require 'active_model'
9
9
 
10
+ alias :require_dependency :require
11
+
10
12
  Minimal::Template.send(:include, Minimal::Template::FormBuilderProxy)
11
13
 
12
14
  ActionView::Template.register_template_handler('rb', Minimal::Template::Handler)
@@ -45,4 +47,4 @@ end
45
47
 
46
48
  class Test::Unit::TestCase
47
49
  include TestMethod
48
- end
50
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minimal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sven Fuchs
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-03-08 00:00:00 +01:00
12
+ date: 2010-03-10 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies: []
15
15