ramaze 0.3.0 → 0.3.5

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.
Files changed (122) hide show
  1. data/Rakefile +3 -2
  2. data/bin/ramaze +9 -3
  3. data/doc/AUTHORS +6 -2
  4. data/doc/CHANGELOG +272 -66
  5. data/doc/GPL +12 -13
  6. data/doc/README.html +729 -0
  7. data/doc/changes.txt +5757 -0
  8. data/doc/changes.xml +5759 -0
  9. data/doc/meta/announcement.txt +48 -39
  10. data/doc/tutorial/todolist.mkd +10 -12
  11. data/examples/blog/start.rb +1 -0
  12. data/examples/caching.rb +1 -0
  13. data/examples/element.rb +3 -0
  14. data/examples/hello.rb +1 -3
  15. data/examples/identity.rb +5 -8
  16. data/examples/layout.rb +1 -0
  17. data/examples/linking.rb +1 -0
  18. data/examples/memleak_detector.rb +1 -0
  19. data/examples/nitro_form.rb +1 -0
  20. data/examples/rammit/start.rb +1 -0
  21. data/examples/rapaste/Rakefile +7 -0
  22. data/examples/rapaste/{src/controller.rb → controller/paste.rb} +28 -3
  23. data/examples/rapaste/{src/model.rb → model/paste.rb} +0 -4
  24. data/examples/rapaste/public/css/display.css +17 -0
  25. data/examples/rapaste/spec/rapaste.rb +2 -2
  26. data/examples/rapaste/start.rb +9 -4
  27. data/examples/rapaste/{template → view}/copy.xhtml +0 -0
  28. data/examples/rapaste/{template → view}/index.xhtml +0 -0
  29. data/examples/rapaste/{template → view}/layout.xhtml +3 -0
  30. data/examples/rapaste/{template → view}/list.xhtml +4 -3
  31. data/examples/rapaste/view/search.xhtml +41 -0
  32. data/examples/rapaste/{template → view}/view.xhtml +0 -0
  33. data/examples/simple.rb +3 -3
  34. data/examples/templates/template/external.amrita +9 -9
  35. data/examples/templates/template/external.redcloth +19 -0
  36. data/examples/templates/template_amrita2.rb +40 -7
  37. data/examples/templates/template_erubis.rb +3 -3
  38. data/examples/templates/template_ezamar.rb +1 -3
  39. data/examples/templates/template_haml.rb +1 -3
  40. data/examples/templates/template_liquid.rb +3 -3
  41. data/examples/templates/template_markaby.rb +1 -3
  42. data/examples/templates/template_nagoro.rb +1 -3
  43. data/examples/templates/template_redcloth.rb +59 -0
  44. data/examples/templates/template_remarkably.rb +1 -3
  45. data/examples/templates/template_xslt.rb +1 -4
  46. data/examples/todolist/src/controller/main.rb +1 -1
  47. data/examples/todolist/start.rb +1 -2
  48. data/examples/upload/start.rb +19 -0
  49. data/examples/upload/view/index.xhtml +25 -0
  50. data/examples/whywiki/start.rb +1 -3
  51. data/examples/wikore/start.rb +3 -0
  52. data/examples/wiktacular/mkd/newpagename/current.mkd +1 -0
  53. data/examples/wiktacular/mkd/newpagename/current.mkd.bak +1 -0
  54. data/examples/wiktacular/start.rb +1 -0
  55. data/lib/proto/controller/main.rb +0 -3
  56. data/lib/proto/public/js/jquery.js +106 -93
  57. data/lib/proto/spec/main.rb +2 -5
  58. data/lib/proto/start.rb +0 -3
  59. data/lib/ramaze.rb +3 -2
  60. data/lib/ramaze/action.rb +6 -10
  61. data/lib/ramaze/adapter/lsws.rb +19 -0
  62. data/lib/ramaze/contrib/email.rb +84 -0
  63. data/lib/ramaze/contrib/email.rb-darcs-backup0 +81 -0
  64. data/lib/ramaze/contrib/gettext.rb +1 -0
  65. data/lib/ramaze/contrib/gettext/parser.rb +46 -0
  66. data/lib/ramaze/contrib/route.rb +3 -36
  67. data/lib/ramaze/controller.rb +4 -6
  68. data/lib/ramaze/controller/resolve.rb +28 -1
  69. data/lib/ramaze/dispatcher.rb +1 -1
  70. data/lib/ramaze/dispatcher/file.rb +17 -0
  71. data/lib/ramaze/global/globalstruct.rb +7 -4
  72. data/lib/ramaze/helper/auth.rb +1 -1
  73. data/lib/ramaze/helper/identity.rb +25 -15
  74. data/lib/ramaze/helper/link.rb +29 -8
  75. data/lib/ramaze/helper/maruku.rb +7 -0
  76. data/lib/ramaze/helper/partial.rb +25 -10
  77. data/lib/ramaze/route.rb +56 -0
  78. data/lib/ramaze/snippets/metaid.rb +17 -0
  79. data/lib/ramaze/spec/helper.rb +0 -2
  80. data/lib/ramaze/spec/helper/mock_http.rb +6 -0
  81. data/lib/ramaze/spec/helper/pretty_output.rb +5 -1
  82. data/lib/ramaze/store/default.rb +3 -1
  83. data/lib/ramaze/template.rb +1 -1
  84. data/lib/ramaze/template/amrita2.rb +21 -15
  85. data/lib/ramaze/template/bijou.rb +39 -0
  86. data/lib/ramaze/template/builder.rb +28 -0
  87. data/lib/ramaze/template/redcloth.rb +24 -0
  88. data/lib/ramaze/template/sass.rb +3 -1
  89. data/lib/ramaze/tool/create.rb +2 -1
  90. data/lib/ramaze/tool/localize.rb +6 -1
  91. data/lib/ramaze/trinity/request.rb +8 -0
  92. data/lib/ramaze/trinity/session.rb +8 -5
  93. data/lib/ramaze/version.rb +1 -1
  94. data/rake_tasks/gem.rake +0 -1
  95. data/rake_tasks/maintenance.rake +4 -1
  96. data/spec/contrib/route.rb +14 -63
  97. data/spec/examples/linking.rb +2 -2
  98. data/spec/examples/templates/template_redcloth.rb +28 -0
  99. data/spec/ramaze/controller/subclass.rb +21 -0
  100. data/spec/ramaze/dispatcher/file.rb +31 -0
  101. data/spec/ramaze/helper/link.rb +46 -0
  102. data/spec/ramaze/helper/partial.rb +22 -1
  103. data/spec/ramaze/helper/template/locals.xhtml +1 -0
  104. data/spec/ramaze/helper/template/recursive_locals.xhtml +7 -0
  105. data/spec/ramaze/params.rb +8 -0
  106. data/spec/ramaze/request.rb +14 -0
  107. data/spec/ramaze/route.rb +107 -0
  108. data/spec/ramaze/session.rb +4 -2
  109. data/spec/ramaze/template/amrita2.rb +21 -7
  110. data/spec/ramaze/template/amrita2/external.amrita +6 -0
  111. data/spec/ramaze/template/amrita2/sum.amrita +1 -1
  112. data/spec/ramaze/template/bijou.rb +25 -0
  113. data/spec/ramaze/template/builder.rb +55 -0
  114. data/spec/ramaze/template/builder/external.rxml +3 -0
  115. data/spec/ramaze/template/haml.rb +15 -0
  116. data/spec/ramaze/template/haml/locals.haml +1 -0
  117. data/spec/ramaze/template/redcloth.rb +38 -0
  118. data/spec/ramaze/template/redcloth/external.redcloth +1 -0
  119. metadata +472 -442
  120. data/examples/rapaste/rapaste.sqlite +0 -0
  121. data/spec/ramaze/template/amrita2/data.amrita +0 -6
  122. data/spec/ramaze/template/amrita2/index.amrita +0 -1
@@ -17,13 +17,14 @@ module Ramaze
17
17
 
18
18
  # mapping of :adapter => to the right class-name.
19
19
  ADAPTER_ALIAS = {
20
- :webrick => :WEBrick,
21
20
  :cgi => :Cgi,
22
21
  :fcgi => :Fcgi,
22
+ :thin => :Thin,
23
+ :lsws => :Lsws,
24
+ :webrick => :WEBrick,
23
25
  :mongrel => :Mongrel,
24
26
  :evented_mongrel => :Mongrel,
25
27
  :swiftiplied_mongrel => :Mongrel,
26
- :thin => :Thin
27
28
  }
28
29
 
29
30
  # mapping of :cache => to the right class-name.
@@ -71,8 +72,10 @@ module Ramaze
71
72
  def adapter
72
73
  if internal = self[:adapter]
73
74
  class_name = ADAPTER_ALIAS.fetch(internal.to_sym, internal)
74
- require("ramaze/adapter"/internal.to_s.downcase)
75
- adapter = Ramaze::Adapter.const_get(class_name)
75
+ unless Ramaze::Adapter.const_defined?(class_name)
76
+ require("ramaze/adapter"/internal.to_s.downcase)
77
+ end
78
+ Ramaze::Adapter.const_get(class_name)
76
79
  end
77
80
  end
78
81
 
@@ -37,7 +37,7 @@ module Ramaze
37
37
  end
38
38
  %{
39
39
  #{open_element}
40
- <form method="POST" action="#{Rs(:login)}"
40
+ <form method="POST" action="#{Rs(:login)}>"
41
41
  <ul style="list-style:none;">
42
42
  <li>Username: <input type="text" name="username" /></li>
43
43
  <li>Password: <input type="password" name="password" /></li>
@@ -3,13 +3,15 @@
3
3
 
4
4
  require 'tmpdir'
5
5
  require 'openid'
6
+ require 'openid/store/filesystem'
7
+ require 'openid/extensions/pape'
6
8
 
7
9
  module Ramaze
8
10
 
9
11
  openid_store_file = File.join(Dir.tmpdir, 'openid-store')
10
12
 
11
13
  # Constant for storing meta-information persistent
12
- OpenIDStore = OpenID::FilesystemStore.new(openid_store_file)
14
+ OpenIDStore = OpenID::Store::Filesystem.new(openid_store_file)
13
15
 
14
16
  # This is called Identity to avoid collisions with the original openid.rb
15
17
  # It provides a nice and simple way to provide and control access over the
@@ -38,18 +40,26 @@ module Ramaze
38
40
  session[:openid_entry] = request.referrer
39
41
 
40
42
  openid_request = openid_consumer.begin(url)
41
- case openid_request.status
42
- when OpenID::FAILURE
43
- flash[:error] = "OpenID - Unable to find openid server for `#{url}'"
44
43
 
45
- redirect_referrer
46
- when OpenID::SUCCESS
47
- root = "http://#{request.http_host}/"
48
- return_to = root[0..-2] + Rs(:openid_complete)
49
- redirect_url = openid_request.redirect_url(root, return_to)
50
-
51
- redirect(redirect_url)
44
+ papereq = OpenID::PAPE::Request.new
45
+ papereq.add_policy_uri(OpenID::PAPE::AUTH_PHISHING_RESISTANT)
46
+ papereq.max_auth_age = 2*60*60
47
+ openid_request.add_extension(papereq)
48
+ openid_request.return_to_args['did_pape'] = 'y'
49
+
50
+ root = "http://#{request.http_host}/"
51
+ return_to = root[0..-2] + Rs(:openid_complete)
52
+ immediate = false
53
+ if openid_request.send_redirect?(root, return_to, immediate)
54
+ redirect_url = openid_request.redirect_url(root, return_to, immediate)
55
+ raw_redirect redirect_url
56
+ else
57
+ # what the hell is @form_text ?
52
58
  end
59
+
60
+ rescue OpenID::OpenIDError => ex
61
+ flash[:error] = "Discovery failed for #{url}: #{ex}"
62
+ raw_redirect Rs(:/)
53
63
  end
54
64
 
55
65
  # After having authenticated at the OpenID server browsers are redirected
@@ -60,19 +70,19 @@ module Ramaze
60
70
  # TODO:
61
71
  # - maybe using StackHelper, but this is a really minimal overlap?
62
72
  def openid_complete
63
- openid_response = openid_consumer.complete(request.params)
73
+ openid_response = openid_consumer.complete(request.params, request.request_uri)
64
74
 
65
75
  case openid_response.status
66
- when OpenID::FAILURE
76
+ when OpenID::Consumer::FAILURE
67
77
  flash[:error] = 'OpenID - Verification failed.'
68
- when OpenID::SUCCESS
78
+ when OpenID::Consumer::SUCCESS
69
79
  session[:openid_identity] = openid_response.identity_url
70
80
  flash[:success] = 'OpenID - Verification done.'
71
81
  end
72
82
 
73
83
  session.delete(:_openid_consumer_service)
74
84
 
75
- redirect session[:openid_entry]
85
+ raw_redirect session[:openid_entry]
76
86
  end
77
87
 
78
88
  private
@@ -26,14 +26,19 @@ module Ramaze
26
26
  # A('title', :href => '/foo?x=y') #> <a href="/foo?x=y">title</a>
27
27
  # A('Home', :href => Rs(:/)) #> <a href="/foo/bar">Home</a>
28
28
 
29
- def A(title, hash = {})
30
- hash[:href] ||= (Rs(title) rescue title)
31
- hash[:href].to_s.sub!(/\A[^\/?]+/){|m| CGI.escape(m) }
29
+ def A(*args)
30
+ hash = args.last.respond_to?(:to_hash) ? args.pop : {}
31
+
32
+ hash[:href] ||= Rs(*args)
33
+ title = hash.delete(:title) ||
34
+ (args.last.respond_to?(:to_s) ? args.last : nil) ||
35
+ hash[:href]
36
+ hash[:href].to_s.sub!(/\A[^\/?]+/) {|m| CGI.escape(m) }
32
37
 
33
38
  args = ['']
34
- hash.each{|k,v| args << %(#{k}="#{v}") if k and v }
39
+ hash.each {|k,v| args << %(#{k}="#{v}") if k and v }
35
40
 
36
- %(<a#{args.join(' ')}>#{title || hash[:href]}</a>)
41
+ %(<a#{args.join(' ')}>#{title}</a>)
37
42
  end
38
43
 
39
44
  # Builds links out of segments.
@@ -79,7 +84,8 @@ module Ramaze
79
84
  # Uses R with Controller.current as first element.
80
85
 
81
86
  def Rs(*atoms)
82
- R(Controller.current, *atoms)
87
+ atoms.unshift Controller.current unless atoms.first.is_a?(Controller)
88
+ R(*atoms)
83
89
  end
84
90
 
85
91
  # Give it a path with character to split at and one to join the crumbs with.
@@ -94,11 +100,26 @@ module Ramaze
94
100
  # <a href="/path">path</a>/
95
101
  # <a href="/path/to">to</a>/
96
102
  # <a href="/path/to/somewhere">somewhere</a>
103
+ #
104
+ # Optionally a href prefix can be specified which generate link
105
+ # names a above, but with the prefix prepended to the href path.
106
+ #
107
+ # Example:
108
+ # breadcrumbs('/path/to/somewhere', '/', '/', '/mycontroller/action')
109
+ #
110
+ # # results in this, newlines added for readability:
111
+ #
112
+ # <a href="/mycontroller/action/path">path</a>/
113
+ # <a href="/mycontroller/action/path/to">to</a>/
114
+ # <a href="/mycontroller/action/path/to/somewhere">somewhere</a>
97
115
 
98
- def breadcrumbs(path, split = '/', join = '/')
116
+ def breadcrumbs(path, split = '/', join = '/', href_prefix = '')
99
117
  atoms = path.split(split).reject{|a| a.empty?}
100
118
  crumbs = atoms.inject([]){|s,v| s << [s.last,v]}
101
- bread = crumbs.map{|a| A(a[-1], :href=>(a*'/'))}
119
+ bread = crumbs.map do |a|
120
+ href_path = href_prefix + a*'/'
121
+ A(a[-1], :href=>(href_path))
122
+ end
102
123
  bread.join(join)
103
124
  end
104
125
  end
@@ -0,0 +1,7 @@
1
+ module Ramaze
2
+ module MarukuHelper
3
+ def maruku(text)
4
+ Maruku.new(text).to_html
5
+ end
6
+ end
7
+ end
@@ -47,19 +47,34 @@ module Ramaze
47
47
  options.keys.each {|x| Request.current.params[x] = saved[x] }
48
48
  end
49
49
 
50
- # Generate from a filename in template_root of the given (or current)
51
- # controller a new action.
52
- # Any option you don't pass is instead taken from Action.current
50
+ # Render the template file in template_root of the
51
+ # current controller.
53
52
 
54
- def render_template(file, options = {})
53
+ def render_template(file, locals = {})
55
54
  current = Action.current
56
- options[:controller] ||= current.controller
57
- options[:instance] ||= current.instance.dup
58
- options[:binding] ||= options[:instance].instance_eval{ binding }
59
- options[:template] = (options[:controller].template_root/file)
55
+ options = { :controller => current.controller,
56
+ :instance => current.instance.dup }
60
57
 
61
- action = Ramaze::Action(options)
62
- action.render
58
+ filename = options[:controller].template_root/file
59
+
60
+ if File.exist?(filename)
61
+ options[:template] = filename
62
+ elsif files = Dir["#{filename}.*"] and files.any?
63
+ options[:template] = files.first
64
+ else
65
+ Inform.warn "render_template: #{filename} does not exist"
66
+ return ''
67
+ end
68
+
69
+ # use method_missing to provide access to locals, if any exist
70
+ options[:instance].meta_def(:method_missing) { |sym, *args|
71
+ return locals[sym] if locals.key?(sym)
72
+ super
73
+ } if locals.any?
74
+
75
+ options[:binding] = options[:instance].instance_eval{ binding }
76
+
77
+ Ramaze::Action(options).render
63
78
  ensure
64
79
  Thread.current[:action] = current
65
80
  end
@@ -0,0 +1,56 @@
1
+ # Copyright (c) 2008 Michael Fellinger m.fellinger@gmail.com
2
+ # All files in this distribution are subject to the terms of the Ruby license.
3
+
4
+ # Ramaze support simple routing using string, regex and lambda based routers.
5
+ # Route are stored in a dictionary, which supports hash-like access but
6
+ # preserves order, so routes are evaluated in the order they are added.
7
+ #
8
+ # String routers are the simplest way to route in Ramaze. One path is
9
+ # translated into another:
10
+ #
11
+ # Ramaze::Route[ '/foo' ] = '/bar'
12
+ # '/foo' => '/bar'
13
+ #
14
+ # Regex routers allow matching against paths using regex. Matches within
15
+ # your regex using () are substituted in the new path using printf-like
16
+ # syntax.
17
+ #
18
+ # Ramaze::Route[ %r!^/(\d+)\.te?xt$! ] = "/text/%d"
19
+ # '/123.txt' => '/text/123'
20
+ # '/789.text' => '/text/789'
21
+ #
22
+ # For more complex routing, lambda routers can be used. Lambda routers are
23
+ # passed in the current path and request object, and must return either a new
24
+ # path string, or nil.
25
+ #
26
+ # Ramaze::Route[ 'name of route' ] = lambda{ |path, request|
27
+ # '/bar' if path == '/foo' and request[:bar] == '1'
28
+ # }
29
+ # '/foo' => '/foo'
30
+ # '/foo?bar=1' => '/bar'
31
+ #
32
+ # Lambda routers can also use this alternative syntax:
33
+ #
34
+ # Ramaze::Route('name of route') do |path, request|
35
+ # '/bar' if path == '/foo' and request[:bar] == '1'
36
+ # end
37
+
38
+ module Ramaze
39
+ class Route
40
+ trait :routes => Dictionary.new
41
+
42
+ class << self
43
+ def [](key)
44
+ trait[:routes][key]
45
+ end
46
+
47
+ def []=(key, value)
48
+ trait[:routes][key] = value
49
+ end
50
+ end
51
+ end
52
+
53
+ def self.Route(name, &block)
54
+ Route[name] = block
55
+ end
56
+ end
@@ -0,0 +1,17 @@
1
+ # from http://whytheluckystiff.net/articles/seeingMetaclassesClearly.html
2
+
3
+ class Object
4
+ # The hidden singleton lurks behind everyone
5
+ def metaclass; class << self; self; end; end
6
+ def meta_eval &blk; metaclass.instance_eval &blk; end
7
+
8
+ # Adds methods to a metaclass
9
+ def meta_def name, &blk
10
+ meta_eval { define_method name, &blk }
11
+ end
12
+
13
+ # Defines an instance method within a class
14
+ def class_def name, &blk
15
+ class_eval { define_method name, &blk }
16
+ end
17
+ end
@@ -72,8 +72,6 @@ shared 'xpath' do
72
72
  require 'rexml/document'
73
73
  require 'rexml/xpath'
74
74
 
75
- include REXML
76
-
77
75
  class Rack::MockResponse
78
76
  def match(xpath = '*')
79
77
  REXML::XPath::match(REXML::Document.new(body), xpath)
@@ -26,6 +26,8 @@ module MockHTTP
26
26
  :referrer => 'HTTP_REFERER',
27
27
  :referer => 'HTTP_REFERER',
28
28
  :cookie => 'HTTP_COOKIE',
29
+ :if_none_match=> 'HTTP_IF_NONE_MATCH',
30
+ :if_modified_since=> 'HTTP_IF_MODIFIED_SINCE',
29
31
  }
30
32
 
31
33
  MOCK_REQUEST = ::Rack::MockRequest.new(Ramaze::Adapter::Fake)
@@ -40,6 +42,10 @@ module MockHTTP
40
42
  MOCK_REQUEST.send(meth, uri, DEFAULTS.merge(options))
41
43
  end
42
44
 
45
+ def raw_mock_request(meth, uri, options = {})
46
+ MOCK_REQUEST.send(meth, uri, DEFAULTS.merge(options))
47
+ end
48
+
43
49
  def process_request(path, query)
44
50
  options = {}
45
51
  FISHING.each{|key, value|
@@ -4,15 +4,18 @@ module Bacon
4
4
 
5
5
  def handle_specification(name)
6
6
  NAME.replace name
7
+ puts NAME
7
8
  yield
9
+ puts
8
10
  end
9
11
 
10
12
  def handle_requirement(description)
13
+ print "- #{description}\n"
11
14
  error = yield
12
15
 
13
16
  unless error.empty?
14
17
  if defined?(Ramaze::Informing)
15
- puts '', " #{NAME} -- #{description} ".center(70, '-'), ''
18
+ puts '', " #{NAME} -- #{description} [FAILED]".center(70, '-'), ''
16
19
  colors = Ramaze::Informer::COLORS
17
20
 
18
21
  until RamazeLogger.log.empty?
@@ -35,6 +38,7 @@ module Bacon
35
38
  end
36
39
 
37
40
  def handle_summary
41
+ puts
38
42
  puts "%d tests, %d assertions, %d failures, %d errors" %
39
43
  Counter.values_at(:specifications, :requirements, :failed, :errors)
40
44
  end
@@ -34,7 +34,9 @@ module Ramaze
34
34
  # pass on all methods inside a transaction
35
35
 
36
36
  def method_missing(meth, *args, &block)
37
- @db.transaction do
37
+ read_only = (meth == :[])
38
+
39
+ @db.transaction(read_only) do
38
40
  @db.send(meth, *args, &block)
39
41
  end
40
42
  end
@@ -16,7 +16,7 @@ module Ramaze
16
16
 
17
17
  ENGINES = {} unless defined?(ENGINES)
18
18
 
19
- %w[ Amrita2 Erubis Haml Liquid Markaby Nagoro None Remarkably Sass XSLT ].
19
+ %w[ Amrita2 Builder Erubis Haml Liquid Markaby Nagoro None RedCloth Remarkably Sass XSLT ].
20
20
  each do |const|
21
21
  autoload(const, "ramaze/template/#{const.downcase}")
22
22
  end
@@ -1,7 +1,16 @@
1
1
  # Copyright (c) 2008 Michael Fellinger m.fellinger@gmail.com
2
2
  # All files in this distribution are subject to the terms of the Ruby license.
3
3
 
4
- require 'amrita2/template'
4
+ require 'amrita2'
5
+
6
+ class Amrita2::Template
7
+
8
+ # Ramaze helpers are available in template contexts.
9
+
10
+ include Ramaze::Helper
11
+ extend Ramaze::Helper
12
+ helper :link, :file, :flash, :cgi
13
+ end
5
14
 
6
15
  module Ramaze
7
16
  module Template
@@ -11,27 +20,24 @@ module Ramaze
11
20
 
12
21
  class Amrita2 < Template
13
22
 
14
- ENGINES[self] = %w[ amrita amr ]
23
+ ENGINES[self] = %w[ amrita amr a2html ]
15
24
 
16
25
  class << self
17
26
 
18
27
  # Takes an Action
19
- # The file is rendered using Amrita2::TemplateFile.
20
- # The Controller is used as the object for expansion.
28
+ # The result or file is rendered using Amrita2::Template.
21
29
  #
22
- # The parameters are set to @params in the controller before expansion.
23
-
24
- def transform action
25
- instance, file = action.instance, action.template
30
+ # The context data are set to @data in the controller before expansion.
26
31
 
27
- raise Ramaze::Error::NoAction,
28
- "No Amrita2 template found for `#{action.path}' on #{action.controller}" unless file
32
+ def transform(action)
33
+ template = wrap_compile(action)
34
+ data = action.instance.instance_variable_get("@data") || {}
35
+ action.instance.extend ::Amrita2::Runtime if data.kind_of? Binding
36
+ template.render_with(data)
37
+ end
29
38
 
30
- template = ::Amrita2::TemplateFile.new(file)
31
- out = ''
32
- instance.instance_variable_set('@params', action.params)
33
- template.expand(out, instance)
34
- out
39
+ def compile(action, template)
40
+ ::Amrita2::Template.new(template)
35
41
  end
36
42
  end
37
43
  end