amrita2 1.9.6 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. data/README +112 -0
  2. data/init.rb +6 -0
  3. data/lib/amrita2/gettext.rb +116 -0
  4. data/lib/amrita2/macro.rb +153 -0
  5. data/lib/amrita2/rails_bridge.rb +172 -26
  6. data/lib/amrita2/template.rb +2634 -234
  7. data/lib/amrita2/testsupport.rb +171 -0
  8. data/lib/amrita2/version.rb +3 -3
  9. data/lib/amrita2.rb +1 -0
  10. data/sample/depot/app/controllers/admin_controller.rb +59 -0
  11. data/sample/depot/app/controllers/application.rb +20 -0
  12. data/sample/depot/app/controllers/info_controller.rb +19 -0
  13. data/sample/depot/app/controllers/login_controller.rb +85 -0
  14. data/sample/depot/app/controllers/store_controller.rb +68 -0
  15. data/sample/depot/app/helpers/admin_helper.rb +7 -0
  16. data/sample/depot/app/helpers/application_helper.rb +10 -0
  17. data/sample/depot/app/helpers/ar_form.rb +169 -0
  18. data/sample/depot/app/helpers/form_tag.rb +24 -0
  19. data/sample/depot/app/helpers/info_helper.rb +7 -0
  20. data/sample/depot/app/helpers/standard_form.rb +73 -0
  21. data/sample/depot/app/helpers/store_helper.rb +14 -0
  22. data/sample/depot/app/models/cart.rb +36 -0
  23. data/sample/depot/app/models/cart_item.rb +26 -0
  24. data/sample/depot/app/models/line_item.rb +34 -0
  25. data/sample/depot/app/models/order.rb +57 -0
  26. data/sample/depot/app/models/product.rb +41 -0
  27. data/sample/depot/app/models/user.rb +83 -0
  28. data/sample/depot/config/boot.rb +49 -0
  29. data/sample/depot/config/environment.rb +83 -0
  30. data/sample/depot/config/environments/development.rb +24 -0
  31. data/sample/depot/config/environments/production.rb +24 -0
  32. data/sample/depot/config/environments/test.rb +24 -0
  33. data/sample/depot/config/routes.rb +10 -0
  34. data/sample/depot/db/migrate/001_create_products.rb +18 -0
  35. data/sample/depot/db/migrate/002_add_price.rb +14 -0
  36. data/sample/depot/db/migrate/003_add_test_data.rb +68 -0
  37. data/sample/depot/db/migrate/004_add_sessions.rb +20 -0
  38. data/sample/depot/db/migrate/005_create_orders.rb +21 -0
  39. data/sample/depot/db/migrate/006_create_line_items.rb +27 -0
  40. data/sample/depot/db/migrate/007_create_users.rb +18 -0
  41. data/sample/depot/db/schema.rb +45 -0
  42. data/sample/depot/public/dispatch.rb +15 -0
  43. data/sample/depot/test/functional/admin_controller_test.rb +54 -0
  44. data/sample/depot/test/functional/info_controller_test.rb +23 -0
  45. data/sample/depot/test/functional/login_controller_test.rb +74 -0
  46. data/sample/depot/test/functional/store_controller_test.rb +57 -0
  47. data/sample/depot/test/integration/dsl_user_stories_test.rb +126 -0
  48. data/sample/depot/test/integration/user_stories_test.rb +70 -0
  49. data/sample/depot/test/performance/order_speed_test.rb +58 -0
  50. data/sample/depot/test/test_helper.rb +16 -0
  51. data/sample/depot/test/unit/cart_test.rb +39 -0
  52. data/sample/depot/test/unit/cart_test1.rb +31 -0
  53. data/sample/depot/test/unit/line_item_test.rb +15 -0
  54. data/sample/depot/test/unit/order_test.rb +15 -0
  55. data/sample/depot/test/unit/product_test.rb +98 -0
  56. data/sample/depot/vendor/plugins/amrita2/init.rb +6 -0
  57. data/sample/hello/hello.rb +22 -0
  58. data/sample/login_engine/app/controllers/application.rb +16 -0
  59. data/sample/login_engine/app/controllers/user_controller.rb +265 -0
  60. data/sample/login_engine/app/helpers/application_helper.rb +3 -0
  61. data/sample/login_engine/app/helpers/form_tag.rb +16 -0
  62. data/sample/login_engine/app/helpers/two_columns.rb +24 -0
  63. data/sample/login_engine/app/helpers/two_columns_form.rb +47 -0
  64. data/sample/login_engine/app/helpers/user_helper.rb +88 -0
  65. data/sample/login_engine/app/models/user.rb +7 -0
  66. data/sample/login_engine/app/models/user_notify.rb +75 -0
  67. data/sample/login_engine/config/boot.rb +45 -0
  68. data/sample/login_engine/config/environment.rb +140 -0
  69. data/sample/login_engine/config/environments/development.rb +21 -0
  70. data/sample/login_engine/config/environments/production.rb +18 -0
  71. data/sample/login_engine/config/environments/test.rb +19 -0
  72. data/sample/login_engine/config/routes.rb +23 -0
  73. data/sample/login_engine/db/migrate/001_create_users.rb +25 -0
  74. data/sample/login_engine/db/schema.rb +25 -0
  75. data/sample/login_engine/lib/config.rb +113 -0
  76. data/sample/login_engine/lib/hpricot_test_extension.rb +80 -0
  77. data/sample/login_engine/lib/login_engine/authenticated_system.rb +113 -0
  78. data/sample/login_engine/lib/login_engine/authenticated_user.rb +155 -0
  79. data/sample/login_engine/lib/login_engine.rb +62 -0
  80. data/sample/login_engine/public/dispatch.rb +10 -0
  81. data/sample/login_engine/test/functional/amrita2_test.rb +267 -0
  82. data/sample/login_engine/test/functional/user_controller_test.rb +544 -0
  83. data/sample/login_engine/test/mocks/mail.rb +14 -0
  84. data/sample/login_engine/test/mocks/time.rb +19 -0
  85. data/sample/login_engine/test/test_helper.rb +31 -0
  86. data/sample/login_engine/test/unit/user_test.rb +116 -0
  87. data/sample/login_engine/vendor/plugins/amrita2/init.rb +6 -0
  88. data/specs/attribute.rb +201 -0
  89. data/specs/datatypes.rb +231 -0
  90. data/specs/dictionary.rb +68 -0
  91. data/specs/erb_cdata.rb +187 -0
  92. data/specs/filters.rb +513 -0
  93. data/specs/gettext/erb_gettext.rb +42 -0
  94. data/specs/gettext/gettext_util.rb +65 -0
  95. data/specs/gettext/static_text.rb +103 -0
  96. data/specs/impl/code_generator.rb +87 -0
  97. data/specs/impl/dynamic_element.rb +92 -0
  98. data/specs/impl/hash_delegator.rb +57 -0
  99. data/specs/impl/parse_opt.rb +34 -0
  100. data/specs/impl/preprocess.rb +823 -0
  101. data/specs/impl/testsupport.rb +89 -0
  102. data/specs/inlineruby.rb +429 -0
  103. data/specs/intro.rb +654 -0
  104. data/specs/loop.rb +203 -0
  105. data/specs/macro.rb +532 -0
  106. data/specs/sample.rb +34 -0
  107. data/specs/sanitize.rb +110 -0
  108. data/specs/template.rb +189 -0
  109. data/specs/trace.rb +97 -0
  110. metadata +138 -19
  111. data/lib/amrita2/core.rb +0 -1897
  112. data/lib/amrita2/rd.rb +0 -314
data/README ADDED
@@ -0,0 +1,112 @@
1
+ = Amrita2 - a xml/xhtml template library for Ruby
2
+
3
+ == Summary
4
+
5
+ Amrita2 is a a xml/xhtml template library for Ruby.
6
+ It makes html documents from a template and a model data.
7
+
8
+ === Key feature
9
+
10
+ specify "XML template" do
11
+ t = Amrita2::Template.new <<-END
12
+ <html>
13
+ <head>
14
+ <title am:src="page_title" />
15
+ </head>
16
+ <body>
17
+ <h1 am:src="header_title" />
18
+ <p class="text" am:src="text">
19
+ <span am:src="template" /> is a html template library for <span am:src="lang" />
20
+ </p>
21
+ </body>
22
+ </html>
23
+ END
24
+
25
+ data = {
26
+ :page_title=>'Amrita2',
27
+ :header_title=>'Hello, Amrita2',
28
+ :text=>{
29
+ :template => 'Amrita2',
30
+ :lang => 'Ruby'
31
+ }
32
+ }
33
+ expected = <<-END
34
+ <html>
35
+ <head>
36
+ <title>Amrita2</title>
37
+ </head>
38
+ <body>
39
+ <h1>Hello, Amrita2</h1>
40
+ <p class="text">Amrita2 is a html template library for Ruby</p>
41
+ </body>
42
+ </html>
43
+ END
44
+ #
45
+ t.render_with(data).should_be_samexml_as(expected)
46
+
47
+ t2 = Amrita2::Template.new <<-END
48
+ <<html<
49
+ <<head<
50
+ <<title:page_title>>
51
+ <<body<
52
+ <<h1:header_title>>
53
+ <<p class="text":text<
54
+ <<:template>> is a html template library for <<:lang>>
55
+ END
56
+ #
57
+ t2.render_with(data).should_be_samexml_as(expected)
58
+ end
59
+
60
+ * The template for amrita2 is a pure html/xhtml document without no
61
+ special tag like <?...?> or <% .. %>
62
+
63
+ * The template can be written by designers using almost any xhtml/xml
64
+ Editor.
65
+
66
+ * Need no change on Ruby code to change the view of _dynamic_ part
67
+ (not only static part) of the template
68
+
69
+ * The model data may be standard Ruby data, Hash, Array, String... or
70
+ an instance of a classes you made.
71
+
72
+ * The output is controlled by _data_ not by logic. So It's easy to
73
+ write, test, debug code. (Good for eXtreamPrograming)
74
+
75
+ Amrita2 mixes a template and model data up to a html document naturally
76
+ matching the +id+ attribute of XML element to model data.
77
+
78
+ === Current version and roadmap
79
+
80
+ Current version is 2.0.0 .
81
+
82
+ === Setup
83
+
84
+ # gem install amrita2
85
+
86
+ == document
87
+
88
+ Start spec/intro.rb or Amrita2 Wiki (http://retro.brain-tokyo.net/projects/amrita2/wiki/Amrita2)
89
+
90
+ == support/developement
91
+
92
+ * http://retro.brain-tokyo.net/projects/amrita2/blog
93
+
94
+ == Download
95
+
96
+ * http://rubyforge.org/projects/amrita2
97
+
98
+ == License
99
+
100
+ Amrita2 is Copyright (c) 2008 Taku Nakajima
101
+ <tnakajima@brain-tokyo.jp>. It is free software, and may be
102
+ redistributed under the terms specified in the README file of the Ruby
103
+ distribution.
104
+
105
+ Sample source code under sample/depot is Amrita2 version of
106
+ Depot Application of "Agile Web Development with Rails".
107
+
108
+ http://www.pragprog.com/titles/rails2/source_code
109
+
110
+ Sample source code under sample/login_engine is Amrita2 version of LoginEngine.
111
+
112
+ http://rails-engines.org/news/2007/01/23/farewell-login_engine-/
data/init.rb ADDED
@@ -0,0 +1,6 @@
1
+ # plugin init files for Ruby On Rails
2
+
3
+ require 'amrita2/rails_bridge'
4
+
5
+ ActionView::Base.register_template_handler "a2html", Amrita2View::Base
6
+
@@ -0,0 +1,116 @@
1
+ require 'amrita2/template'
2
+ require 'gettext/rgettext'
3
+
4
+ module Amrita2
5
+ module Core
6
+ class CompoundElement # :nodoc: all
7
+ def get_erb_source
8
+ @children.collect do |c|
9
+ c.get_erb_source
10
+ end.join("\n")
11
+ end
12
+ end
13
+
14
+ class ErbNode # :nodoc: all
15
+ def get_erb_source
16
+ return @node.to_s
17
+ end
18
+ end
19
+
20
+ class DynamicElement # :nodoc: all
21
+ def get_erb_source
22
+ @children.collect do |c|
23
+ c.get_erb_source
24
+ end.join("\n")
25
+ end
26
+ end
27
+
28
+
29
+ class RootElement < DynamicElement # :nodoc: all
30
+ attr_accessor :text_domain
31
+ compile_old = self.instance_method(:compile)
32
+
33
+ define_method(:compile) do |cg|
34
+ cg.code("bindtextdomain(#{@text_domain.inspect})")
35
+ compile_old.bind(self).call(cg)
36
+ end
37
+
38
+ end
39
+
40
+ class Template
41
+ attr_accessor :text_domain
42
+ def compile_for_gettext
43
+ setup
44
+ end
45
+
46
+ def get_erb_source_for_gettext
47
+ setup
48
+ @root.get_erb_source
49
+ end
50
+ end
51
+ end
52
+
53
+ module GetTextBridge # :nodoc: all
54
+ class TextNodeForGetText < Core::StaticNode
55
+ def dynamic?
56
+ true
57
+ end
58
+
59
+ def render_me(cg)
60
+ #text = @node.to_s.strip
61
+
62
+ # to keep &nbsp;
63
+ text = ""
64
+ @node.output(text, :preserve=>true)
65
+ text.strip!
66
+ cg.put_string_expression("_(#{text.inspect}) % $_") if text != ""
67
+ end
68
+ def get_erb_source
69
+ return ""
70
+ end
71
+ end
72
+ end
73
+
74
+ module Filters
75
+ class GetTextFilter < Filters::Base
76
+ def parse_node(de, node)
77
+ case node
78
+ when Hpricot::CData
79
+ super
80
+ when Hpricot::Text
81
+ Amrita2::GetTextBridge::TextNodeForGetText.new(de, node)
82
+ else
83
+ super
84
+ end
85
+ end
86
+ end
87
+ end
88
+
89
+ module GetTextParser # :nodoc: all
90
+ include Amrita2
91
+ include Amrita2::GetTextBridge
92
+
93
+ module_function
94
+ def target?(file)
95
+ File.extname(file) == '.a2html'
96
+ end
97
+
98
+ def parse(file, ary)
99
+ t = Template.new(File::open(file).read) do |e, src, filters|
100
+ filters << Filters::GetTextFilter.new
101
+ end
102
+
103
+
104
+ src = t.compile_for_gettext
105
+ RubyParser.parse_lines(file, [src], ary)
106
+ src = t.get_erb_source_for_gettext
107
+ erb = ERB.new(src).src.split(/$/)
108
+ RubyParser.parse_lines(file, erb, ary)
109
+ ary.collect do |msgid, fnameandline|
110
+ [msgid, fnameandline.gsub(/\d+$/, "-")]
111
+ end
112
+ end
113
+ end
114
+ end
115
+
116
+ GetText::RGetText.add_parser(Amrita2::GetTextParser)
@@ -0,0 +1,153 @@
1
+ require 'amrita2/template'
2
+
3
+ module Amrita2
4
+
5
+ class Core::Template
6
+ def add_macro(m)
7
+ @macros ||= []
8
+ @macros << m
9
+ end
10
+ alias use_macro add_macro
11
+
12
+ compile_old = instance_method(:compile)
13
+
14
+ define_method(:compile) do |*args|
15
+ macros = @macros
16
+ if macros and macros.size > 0
17
+ filter_setup do |e, name ,filters|
18
+ filters << MacroFilter.new(*macros)
19
+ end
20
+ end
21
+ compile_old.bind(self).call(*args)
22
+ end
23
+ end
24
+
25
+ module Macro # :nodoc: all
26
+ class Base
27
+ def initialize
28
+ @mt = Template.new(get_macro_template, :amrita_prefix=>"macro:", :inline_ruby=>true)
29
+ @option = {}
30
+ @option = self.class.const_get(:Option) if self.class.const_defined?(:Option)
31
+ raise "Macro Option is not defined propery in #{self.class} #{@option.inspect}" unless @option.kind_of?(Hash)
32
+ end
33
+
34
+ def get_macro_template
35
+ self.class.const_get(:TemplateText)
36
+ end
37
+
38
+ def get_element_name
39
+ #self.class.const_get(:ElementName)
40
+ @option[:tag] || underscore(self.class.name)
41
+ end
42
+
43
+ def process(de, element)
44
+ preprocess_element(@mt, element)
45
+ end
46
+
47
+ def match_element(element)
48
+ element.name == get_element_name.to_s
49
+ end
50
+
51
+ def macro_data(element)
52
+ element.as_amrita_dictionary(@option)
53
+ end
54
+
55
+ def preprocess_element(mt, element)
56
+ if @option[:trace]
57
+ mt.set_trace(@option[:trace])
58
+ @option[:trace] << (macro_data(element)).inspect
59
+ end
60
+ mt.amrita_prefix = "macro:"
61
+ mt.render_with(macro_data(element))
62
+ end
63
+
64
+ private
65
+ # from activesupport
66
+ def underscore(camel_cased_word)
67
+ camel_cased_word.to_s.gsub(/::/, '/').
68
+ gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
69
+ gsub(/([a-z\d])([A-Z])/,'\1_\2').
70
+ tr("-", "_").
71
+ downcase
72
+ end
73
+ end
74
+ end
75
+
76
+ module Filters
77
+ class MacroFilter < Base
78
+ include Amrita2
79
+ include Util
80
+ include OptionSupport
81
+ attr_reader :macros
82
+
83
+ def initialize(*macros)
84
+ @macros = macros.collect do |m|
85
+ case m
86
+ when Class
87
+ m.new
88
+ else
89
+ m
90
+ end
91
+ end
92
+ @element_names = {}
93
+ @macros.each do |m|
94
+ @element_names[m.get_element_name.to_s] = true
95
+ end
96
+ end
97
+
98
+ def check_element(element)
99
+ return true if @element_names[element.name]
100
+ element.each_child do |c|
101
+ next unless c.kind_of?(Hpricot::Elem)
102
+ return true if @element_names[c.name] or check_element(c)
103
+ end
104
+ false
105
+ end
106
+
107
+ def filter_element(de, element)
108
+ return element unless check_element(element)
109
+
110
+ @macros.each do |m|
111
+ if m.match_element(element)
112
+ ret = m.process(de, element)
113
+ ret = Core::PreProcessor.new.process(ret.dup)
114
+ ret.gsub!('<%%', '<%')
115
+ ret.gsub!('%%>', '%>')
116
+ root = Hpricot.make("<_ />").first
117
+ Hpricot.make(ret, :xml=>true).each do |e|
118
+ root.insert_after(e, nil)
119
+ end
120
+ element = replace_target_src(root)
121
+ else
122
+ element.each_child do |c|
123
+ next unless c.kind_of?(Hpricot::Elem)
124
+ cc = filter_element(de, c)
125
+ element.replace_child(c, cc) if c != cc
126
+ end
127
+ end
128
+ end
129
+ element
130
+ end
131
+
132
+ def replace_target_src(e)
133
+ %w(src filter v skipif for).each do |k|
134
+ e.set_attribute("am:#{k}", e.attributes["target_#{k}"]) if e.attributes["target_#{k}"]
135
+ e.delete_attribute("target_#{k}")
136
+ end
137
+ e.each_child do |c|
138
+ next unless c.kind_of?(Hpricot::Elem)
139
+ replace_target_src(c)
140
+ end
141
+ e
142
+ end
143
+
144
+ def element_render_code(de, cg, element, &block)
145
+ if (element.name == 'macroroot')
146
+ yield
147
+ else
148
+ super
149
+ end
150
+ end
151
+ end
152
+ end
153
+ end
@@ -1,40 +1,186 @@
1
1
  require 'amrita2/template'
2
2
 
3
- module Amrita2View
3
+ require 'action_view'
4
+
5
+ module ActionView # :nodoc: all
6
+ class Base #:nodoc:
7
+ include Amrita2::Runtime
8
+ end
9
+ end
10
+
11
+ module ActiveRecord # :nodoc: all
12
+ class Base
13
+ include Amrita2::DictionaryData
14
+ end
15
+
16
+ class ConnectionAdapters::Column
17
+ include Amrita2::DictionaryData
18
+ end
19
+ end
20
+
21
+ module ActionController # :nodoc: all
22
+ class Pagination::Paginator
23
+ include Amrita2::DictionaryData
24
+ end
25
+ end
26
+
27
+
28
+ module Amrita2View # :nodoc: all
4
29
  class Base
30
+ include Amrita2
31
+ include Amrita2::Filters
32
+ include Amrita2::Runtime
33
+ include Amrita2::Util
34
+
35
+ CompileTimeBinding = binding
5
36
  @@compiled_amrita2_templates = {}
6
37
 
38
+ @@text_domain = nil
39
+ cattr_accessor :text_domain
40
+
7
41
  def initialize( action_view )
8
42
  @action_view = action_view
9
- @action_view.extend(Amrita2::Runtime)
10
- end
11
-
12
- def render( template, local_assigns={} )
13
- action_name = @action_view.controller.action_name
14
- tmpl_method = action_name + "_setup_template"
15
- tmpl = @@compiled_amrita2_templates[template] ||=
16
- if @action_view.respond_to?(tmpl_method)
17
- @action_view.send(tmpl_method, template)
18
- else
19
- t = Amrita2::TemplateText.new(template)
20
- b = @action_view.instance_eval { binding }
21
- t.use_erb(b)
22
- t
23
- end
43
+ end
44
+
45
+ def render(template, local_assigns={})
46
+ Thread::current[:amrita_rails_view] = @action_view
47
+ if template.kind_of?(String)
48
+ render_amrita(template, local_assigns)
49
+ else
50
+ @action_view.render(template, local_assigns)
51
+ end
52
+ end
53
+
54
+ def setup_template(template)
55
+ setup_template_default(template)
56
+ end
24
57
 
25
- po_method = action_name + "_po"
26
- po = nil
27
- if @action_view.respond_to?(po_method)
28
- po = @action_view.send(po_method)
58
+ def setup_template_default(template)
59
+ if Amrita2::const_defined?(:GetTextBridge)
60
+ t = Amrita2::Template.new(template) do |e, src, filters|
61
+ filters << Amrita2::Filters::GetTextFilter.new
62
+ end
63
+ t.text_domain = text_domain
64
+ bindtextdomain(t.text_domain)
65
+ #t.set_trace(STDOUT)
66
+ t.compiletime_binding = CompileTimeBinding
67
+ t
29
68
  else
30
- po = @action_view.controller
31
- end
69
+ t = Amrita2::Template.new(template)
70
+ t.compiletime_binding = CompileTimeBinding
71
+ t
72
+ end
73
+ end
32
74
 
33
- tmpl.expand(out="", po)
34
- out
35
- rescue
36
- $!.to_s + $@.join("<br>")
75
+ def render_amrita(template, local_assigns)
76
+ @@compiled_amrita2_templates[template] ||= setup_template(template)
77
+ tmpl = @@compiled_amrita2_templates[template]
78
+ b = setup_binding_of_view(local_assigns)
79
+ tmpl.render_with(b)
80
+ end
81
+
82
+ def setup_binding_of_view(local_assigns)
83
+ @action_view.instance_eval do
84
+ evaluate_assigns
85
+ b = binding
86
+ local_assigns.each do |k, v|
87
+ amrita_set_context_value(v)
88
+ eval "#{k}=amrita_get_context_value",b
89
+ end
90
+ b
91
+ end
92
+ end
93
+ end
94
+ module Helper
95
+ include ActionView::Helpers::UrlHelper
96
+
97
+ def view
98
+ @view ||= Thread::current[:amrita_rails_view]
99
+ end
100
+
101
+ def eval_in_view(&block)
102
+ view.instance_eval &block
103
+ end
104
+
105
+ def eval_in_view_without_escape(&block)
106
+ Amrita2::SanitizedString[eval_in_view(&block)]
37
107
  end
38
108
  end
39
109
  end
40
110
 
111
+ =begin
112
+
113
+ class WithObject < Amrita2::Macro::Base
114
+ TemplateText = <<-'END'
115
+ <<%<
116
+ <% Thread::current[:amrita2_form_object] = $_[:name] || $_[:object] %>
117
+ <<_ :| Attr[:target_src=>:object]<
118
+ <<:contents>>
119
+ END
120
+
121
+ Option = {
122
+ :tag => "a:with_object",
123
+ :use_contents => :contents,
124
+ }
125
+
126
+ end
127
+
128
+ class Input < Amrita2::Macro::Base
129
+ TemplateText = <<-'END'
130
+ <<%<
131
+ <%
132
+ object = $_.delete(:object) || Thread::current[:amrita2_form_object]
133
+ input_id = $_.delete(:id)
134
+ other = $_.collect do |k, v|
135
+ "#{k}='#{v}'"
136
+ end
137
+ %>
138
+ <input id="<%= object %>_<%= input_id %>" name="<%= object %>[<%= input_id%>]" <%= other %> target_filter="Attr[:value=><%= input_id.intern.inspect %>]"/>
139
+ END
140
+
141
+ Option = {
142
+ :tag => "a:input"
143
+ }
144
+ end
145
+
146
+ class TextField < Amrita2::Macro::Base
147
+ TemplateText = <<-'END'
148
+ <<%<
149
+ <%
150
+ object = $_.delete(:object) || Thread::current[:amrita2_form_object]
151
+ input_id = $_.delete(:id)
152
+ $_[:size] ||= 30
153
+ other = $_.collect do |k, v|
154
+ "#{k}='#{v}'"
155
+ end
156
+ %>
157
+ <input type="text" id="<%= object %>_<%= input_id %>" name="<%= object %>[<%= input_id%>]" <%= other %> target_filter="Attr[:value=><%= input_id.intern.inspect %>]"/>
158
+ END
159
+
160
+ Option = {
161
+ :tag => "a:text_field",
162
+ }
163
+ end
164
+
165
+ class TextArea < Amrita2::Macro::Base
166
+ TemplateText = <<-'END'
167
+ <<%<
168
+ <%
169
+ object = $_.delete(:object) || Thread::current[:amrita2_form_object]
170
+ input_id = $_.delete(:id)
171
+ $_[:cols] ||= 40
172
+ $_[:rows] ||= 20
173
+ other = $_.collect do |k, v|
174
+ "#{k}='#{v}'"
175
+ end
176
+ %>
177
+ <textarea id="<%= object %>_<%= input_id %>" name="<%= object %>[<%= input_id%>]" <%= other %> target_filter="Attr[:body=><%= input_id.intern.inspect %>]"/>
178
+ END
179
+
180
+ Option = {
181
+ :tag => "a:textarea",
182
+ }
183
+ end
184
+ =end
185
+
186
+