kwartz 3.0.0 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (179) hide show
  1. data/ChangeLog +36 -1
  2. data/LGPL +504 -0
  3. data/README.txt +16 -2
  4. data/bin/kwartz +1 -1
  5. data/doc-api/classes/Kwartz.html +47 -1
  6. data/doc-api/classes/Kwartz/Assertion.html +6 -6
  7. data/doc-api/classes/Kwartz/AssertionError.html +6 -6
  8. data/doc-api/classes/Kwartz/AttrInfo.html +42 -42
  9. data/doc-api/classes/Kwartz/BaseError.html +12 -12
  10. data/doc-api/classes/Kwartz/BaseTranslator.html +210 -43
  11. data/doc-api/classes/Kwartz/CharacterType.html +24 -24
  12. data/doc-api/classes/Kwartz/CommandOptionError.html +7 -7
  13. data/doc-api/classes/Kwartz/CommandOptions.html +49 -49
  14. data/doc-api/classes/Kwartz/Config.html +6 -1
  15. data/doc-api/classes/Kwartz/ConvertError.html +14 -14
  16. data/doc-api/classes/Kwartz/Converter.html +31 -30
  17. data/doc-api/classes/Kwartz/CssStyleParser.html +79 -57
  18. data/doc-api/classes/Kwartz/Defun.html +313 -0
  19. data/doc-api/classes/Kwartz/DocumentRuleset.html +58 -58
  20. data/doc-api/classes/Kwartz/ElementExpander.html +32 -32
  21. data/doc-api/classes/Kwartz/ElementInfo.html +29 -29
  22. data/doc-api/classes/Kwartz/ElementRuleset.html +126 -96
  23. data/doc-api/classes/Kwartz/EperlHandler.html +108 -84
  24. data/doc-api/classes/Kwartz/EperlTranslator.html +7 -7
  25. data/doc-api/classes/Kwartz/ErubisHandler.html +2 -2
  26. data/doc-api/classes/Kwartz/ErubisTranslator.html +8 -8
  27. data/doc-api/classes/Kwartz/ErubyHandler.html +2 -220
  28. data/doc-api/classes/Kwartz/ErubyTranslator.html +7 -7
  29. data/doc-api/classes/Kwartz/ExpandStatement.html +20 -20
  30. data/doc-api/classes/Kwartz/Handler.html +122 -117
  31. data/doc-api/classes/Kwartz/HandlerArgument.html +215 -0
  32. data/doc-api/classes/Kwartz/Helper.html +112 -0
  33. data/doc-api/classes/Kwartz/Helper/ActionViewHelper.html +221 -0
  34. data/doc-api/classes/Kwartz/Helper/RailsTemplate.html +630 -0
  35. data/doc-api/classes/Kwartz/JstlHandler.html +208 -193
  36. data/doc-api/classes/Kwartz/JstlTranslator.html +15 -15
  37. data/doc-api/classes/Kwartz/KwartzError.html +6 -6
  38. data/doc-api/classes/Kwartz/Main.html +39 -23
  39. data/doc-api/classes/Kwartz/NativeExpression.html +18 -18
  40. data/doc-api/classes/Kwartz/NativeStatement.html +25 -25
  41. data/doc-api/classes/Kwartz/Node.html +6 -6
  42. data/doc-api/classes/Kwartz/PIErubisHandler.html +113 -0
  43. data/doc-api/classes/Kwartz/PIErubisTranslator.html +200 -0
  44. data/doc-api/classes/Kwartz/ParseError.html +6 -6
  45. data/doc-api/classes/Kwartz/PhpHandler.html +102 -83
  46. data/doc-api/classes/Kwartz/PhpTranslator.html +14 -14
  47. data/doc-api/classes/Kwartz/PresentationLogicParser.html +136 -128
  48. data/doc-api/classes/Kwartz/PrintStatement.html +19 -19
  49. data/doc-api/classes/Kwartz/RailsHandler.html +121 -118
  50. data/doc-api/classes/Kwartz/RailsTranslator.html +7 -7
  51. data/doc-api/classes/Kwartz/RubyHandler.html +349 -0
  52. data/doc-api/classes/Kwartz/RubyStyleParser.html +85 -85
  53. data/doc-api/classes/Kwartz/RubyTranslator.html +218 -0
  54. data/doc-api/classes/Kwartz/StatementHelper.html +479 -0
  55. data/doc-api/classes/Kwartz/StrutsTranslator.html +12 -12
  56. data/doc-api/classes/Kwartz/TagInfo.html +28 -28
  57. data/doc-api/classes/Kwartz/TextConverter.html +28 -28
  58. data/doc-api/classes/Kwartz/Translator.html +42 -42
  59. data/doc-api/classes/Kwartz/Util.html +284 -0
  60. data/doc-api/created.rid +1 -1
  61. data/doc-api/files/__/README_txt.html +30 -3
  62. data/doc-api/files/kwartz/assert_rb.html +1 -1
  63. data/doc-api/files/kwartz/binding/eperl_rb.html +2 -2
  64. data/doc-api/files/kwartz/binding/erubis_rb.html +3 -3
  65. data/doc-api/files/kwartz/binding/eruby_rb.html +3 -2
  66. data/doc-api/files/kwartz/binding/jstl_rb.html +2 -2
  67. data/doc-api/files/kwartz/binding/php_rb.html +2 -2
  68. data/doc-api/files/kwartz/binding/pierubis_rb.html +116 -0
  69. data/doc-api/files/kwartz/binding/rails_rb.html +2 -2
  70. data/doc-api/files/kwartz/binding/ruby_rb.html +115 -0
  71. data/doc-api/files/kwartz/binding/struts_rb.html +1 -1
  72. data/doc-api/files/kwartz/config_rb.html +2 -2
  73. data/doc-api/files/kwartz/converter_rb.html +3 -2
  74. data/doc-api/files/kwartz/defun_rb.html +116 -0
  75. data/doc-api/files/kwartz/error_rb.html +1 -1
  76. data/doc-api/files/kwartz/helper/rails_rb.html +123 -0
  77. data/doc-api/files/kwartz/main_rb.html +5 -2
  78. data/doc-api/files/kwartz/node_rb.html +2 -2
  79. data/doc-api/files/kwartz/parser_rb.html +2 -2
  80. data/doc-api/files/kwartz/translator_rb.html +2 -2
  81. data/doc-api/files/kwartz/util/assert-text-equal_rb.html +1 -1
  82. data/doc-api/files/kwartz/util/testcase-helper_rb.html +2 -2
  83. data/doc-api/files/kwartz/util_rb.html +107 -0
  84. data/doc-api/files/kwartz_rb.html +3 -2
  85. data/doc-api/fr_class_index.html +11 -0
  86. data/doc-api/fr_file_index.html +5 -0
  87. data/doc-api/fr_method_index.html +242 -190
  88. data/doc/p-pattern.html +94 -94
  89. data/doc/reference.html +847 -612
  90. data/doc/users-guide.html +744 -241
  91. data/examples/rails1/README +2 -2
  92. data/examples/rails1/application_helper.rb +2 -27
  93. data/examples/rails1/link_to.plogic +5 -5
  94. data/examples/rails1/list.plogic +2 -2
  95. data/examples/rails2/app/controllers/application.rb +14 -0
  96. data/examples/rails2/app/controllers/groups_controller.rb +47 -0
  97. data/examples/rails2/app/controllers/members_controller.rb +56 -0
  98. data/examples/rails2/app/helpers/application_helper.rb +6 -0
  99. data/examples/rails2/app/helpers/groups_helper.rb +2 -0
  100. data/examples/rails2/app/helpers/members_helper.rb +2 -0
  101. data/examples/rails2/app/models/group.rb +2 -0
  102. data/examples/rails2/app/models/member.rb +3 -0
  103. data/examples/rails2/app/views/groups/_form.html +30 -0
  104. data/examples/rails2/app/views/groups/_form.plogic +11 -0
  105. data/examples/rails2/app/views/groups/_link.plogic +19 -0
  106. data/examples/rails2/app/views/groups/_read.plogic +7 -0
  107. data/examples/rails2/app/views/groups/edit.cfg.yaml +2 -0
  108. data/examples/rails2/app/views/groups/edit.html +26 -0
  109. data/examples/rails2/app/views/groups/edit.plogic +9 -0
  110. data/examples/rails2/app/views/groups/list.html +48 -0
  111. data/examples/rails2/app/views/groups/list.plogic +32 -0
  112. data/examples/rails2/app/views/groups/new.cfg.yaml +2 -0
  113. data/examples/rails2/app/views/groups/new.html +27 -0
  114. data/examples/rails2/app/views/groups/new.plogic +9 -0
  115. data/examples/rails2/app/views/groups/show.html +27 -0
  116. data/examples/rails2/app/views/groups/show.plogic +2 -0
  117. data/examples/rails2/app/views/layouts/groups.html +23 -0
  118. data/examples/rails2/app/views/layouts/groups.plogic +11 -0
  119. data/examples/rails2/app/views/layouts/members.html +23 -0
  120. data/examples/rails2/app/views/layouts/members.plogic +11 -0
  121. data/examples/rails2/app/views/layouts/members2.html +24 -0
  122. data/examples/rails2/app/views/layouts/members2.plogic +11 -0
  123. data/examples/rails2/app/views/members/_form.plogic +27 -0
  124. data/examples/rails2/app/views/members/_link.plogic +19 -0
  125. data/examples/rails2/app/views/members/_read.plogic +29 -0
  126. data/examples/rails2/app/views/members/edit.cfg.yaml +6 -0
  127. data/examples/rails2/app/views/members/edit.html +27 -0
  128. data/examples/rails2/app/views/members/edit.plogic +10 -0
  129. data/examples/rails2/app/views/members/list.html +53 -0
  130. data/examples/rails2/app/views/members/list.plogic +32 -0
  131. data/examples/rails2/app/views/members/new.html +61 -0
  132. data/examples/rails2/app/views/members/new.plogic +17 -0
  133. data/examples/rails2/app/views/members/show.html +41 -0
  134. data/examples/rails2/app/views/members/show.plogic +3 -0
  135. data/examples/rails2/db/create-tables.mysql.sql +27 -0
  136. data/examples/rails2/db/create-tables.pgsql.sql +27 -0
  137. data/examples/rails2/db/insert-data.sql +21 -0
  138. data/examples/rails2/db/tabledef.yaml +51 -0
  139. data/kwartz.gemspec +4 -4
  140. data/lib/kwartz.rb +10 -2
  141. data/lib/kwartz/assert.rb +1 -1
  142. data/lib/kwartz/binding/eperl.rb +85 -61
  143. data/lib/kwartz/binding/erubis.rb +6 -8
  144. data/lib/kwartz/binding/eruby.rb +5 -120
  145. data/lib/kwartz/binding/jstl.rb +116 -101
  146. data/lib/kwartz/binding/php.rb +79 -60
  147. data/lib/kwartz/binding/pierubis.rb +58 -0
  148. data/lib/kwartz/binding/rails.rb +45 -42
  149. data/lib/kwartz/binding/ruby.rb +193 -0
  150. data/lib/kwartz/binding/struts.rb +1 -1
  151. data/lib/kwartz/config.rb +4 -3
  152. data/lib/kwartz/converter.rb +231 -68
  153. data/lib/kwartz/defun.rb +126 -0
  154. data/lib/kwartz/error.rb +1 -1
  155. data/lib/kwartz/helper/rails.rb +437 -0
  156. data/lib/kwartz/main.rb +30 -38
  157. data/lib/kwartz/node.rb +46 -31
  158. data/lib/kwartz/parser.rb +43 -15
  159. data/lib/kwartz/translator.rb +104 -6
  160. data/lib/kwartz/util.rb +113 -0
  161. data/lib/kwartz/util/assert-text-equal.rb +1 -1
  162. data/lib/kwartz/util/testcase-helper.rb +26 -8
  163. data/test/test-compile.rb +3 -3
  164. data/test/test-compile.yaml +135 -5
  165. data/test/test-converter.rb +16 -8
  166. data/test/test-converter.yaml +307 -76
  167. data/test/test-directives.rb +1 -1
  168. data/test/test-directives.yaml +964 -979
  169. data/test/test-main.rb +61 -146
  170. data/test/test-main.yaml +235 -0
  171. data/test/test-parser.rb +10 -12
  172. data/test/test-parser.yaml +484 -326
  173. data/test/test-rails.rb +1 -1
  174. data/test/test-rails.yaml +37 -37
  175. data/test/test-ruleset.rb +1 -1
  176. data/test/test-ruleset.yaml +34 -40
  177. data/test/test.rb +1 -1
  178. metadata +82 -3
  179. data/COPYING +0 -340
@@ -0,0 +1,41 @@
1
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2
+ <html>
3
+ <head>
4
+ <title>Show member</title>
5
+ </head>
6
+ <body>
7
+
8
+ <h1 id="page_title">Show member</h1>
9
+
10
+ <div id="page_content">
11
+ <p>
12
+ <b>Name:</b>
13
+ <span id="mark:member_name">Foo</span>
14
+ </p>
15
+
16
+ <p>
17
+ <b>Email:</b>
18
+ <span id="mark:member_email">foo@mail.com</span>
19
+ </p>
20
+
21
+ <p>
22
+ <b>Birth:</b>
23
+ <span id="mark:member_birth">2000-01-01</span>
24
+ </p>
25
+
26
+ <p>
27
+ <b>Gender:</b>
28
+ <span id="mark:member_gender">Woman</span>
29
+ </p>
30
+
31
+ <p>
32
+ <b>Group:</b>
33
+ <span id="mark:member_group">admin</span>
34
+ </p>
35
+
36
+ <a href="#" id="link_to_edit">Edit</a> |
37
+ <a href="#" id="link_to_list">Back</a>
38
+ </div>
39
+
40
+ </body>
41
+ </html>
@@ -0,0 +1,3 @@
1
+ @import '_link.plogic';
2
+ @import '_read.plogic';
3
+
@@ -0,0 +1,27 @@
1
+ ----------------------------------------------------------------------
2
+ -- DDL for MySQL
3
+ -- generated by kwatable with template 'ddl-mysql.eruby'
4
+ -- at Sun Sep 17 21:18:57 JST 2006
5
+ ----------------------------------------------------------------------
6
+
7
+ -- group master table
8
+ drop table if exists groups;
9
+ create table groups (
10
+ id integer auto_increment primary key,
11
+ name varchar(63) not null unique,
12
+ `desc` text
13
+ );
14
+
15
+ -- member master table
16
+ drop table if exists members;
17
+ create table members (
18
+ id integer auto_increment primary key,
19
+ name varchar(63) not null unique,
20
+ `desc` text ,
21
+ email varchar(63) ,
22
+ gender enum('M', 'W', 'X') ,
23
+ birth date ,
24
+ group_id integer not null references groups(id),
25
+ created_at timestamp not null,
26
+ updated_at timestamp not null
27
+ );
@@ -0,0 +1,27 @@
1
+ ----------------------------------------------------------------------
2
+ -- DDL for PostgreSQL
3
+ -- generated by kwatable with template 'ddl-postgresql.eruby'
4
+ -- at Sun Sep 17 21:18:58 JST 2006
5
+ ----------------------------------------------------------------------
6
+
7
+ -- group master table
8
+ drop table groups;
9
+ create table groups (
10
+ id serial primary key,
11
+ name varchar(63) not null unique,
12
+ "desc" text
13
+ );
14
+
15
+ -- member master table
16
+ drop table members;
17
+ create table members (
18
+ id serial primary key,
19
+ name varchar(63) not null unique,
20
+ "desc" text ,
21
+ email varchar(63) ,
22
+ gender varchar(1) , -- M,W,X
23
+ birth date ,
24
+ group_id integer not null references groups(id),
25
+ created_at timestamp not null,
26
+ updated_at timestamp not null
27
+ );
@@ -0,0 +1,21 @@
1
+ -- groups
2
+ delete from groups;
3
+ insert into groups values (null, 'admin', 'administrators');
4
+ insert into groups values (null, 'users', 'common users');
5
+ insert into groups values (null, 'guest', 'guest group');
6
+
7
+ -- members
8
+ delete from members;
9
+ insert into members values (null, 'root', 'administrator', 'root@localhost', 'X', null, 1, current_timestamp, current_timestamp);
10
+ insert into members values (null, 'guest', 'guest user', null, 'X', null, 3, current_timestamp, current_timestamp);
11
+ insert into members values (null, 'foo', 'user foo', 'foo@mail.com', 'W', '1980-02-03', 2, current_timestamp, current_timestamp);
12
+ insert into members values (null, 'bar', 'user bar', 'bar@mail.net', 'W', '1981-04-05', 2, current_timestamp, current_timestamp);
13
+ insert into members values (null, 'baz', 'user baz', 'baz@mail.org', 'M', '1982-06-07', 2, current_timestamp, current_timestamp);
14
+ insert into members values (null, '<b>"X&Y"</b>', '<i>"escape test&"</i>', '"<&>"@xxx.com', 'W', '1990-01-01', 2, current_timestamp, current_timestamp);
15
+ insert into members values (null, 'aaa', 'user aaa', 'aaa@aaa.com', 'W', '1990-01-01', 2, current_timestamp, current_timestamp);
16
+ insert into members values (null, 'bbb', 'user bbb', 'bbb@bbb.com', 'W', '1990-01-01', 2, current_timestamp, current_timestamp);
17
+ insert into members values (null, 'ccc', 'user ccc', 'ccc@ccc.com', 'W', '1990-01-01', 2, current_timestamp, current_timestamp);
18
+ insert into members values (null, 'ddd', 'user ddd', 'ddd@ddd.com', 'W', '1990-01-01', 2, current_timestamp, current_timestamp);
19
+ insert into members values (null, 'eee', 'user eee', 'eee@eee.com', 'W', '1990-01-01', 2, current_timestamp, current_timestamp);
20
+ insert into members values (null, 'fff', 'user fff', 'fff@fff.com', 'W', '1990-01-01', 2, current_timestamp, current_timestamp);
21
+ insert into members values (null, 'ggg', 'user ggg', 'ggg@ggg.com', 'W', '1990-01-01', 2, current_timestamp, current_timestamp);
@@ -0,0 +1,51 @@
1
+
2
+ columns:
3
+ - name: id
4
+ type: integer
5
+ required: yes
6
+ serial: yes
7
+ ident: yes
8
+ - name: name
9
+ type: string
10
+ width: 63
11
+ required: yes
12
+ unique: yes
13
+ - name: desc
14
+ type: text
15
+ - name: created_at
16
+ type: timestamp
17
+ required: yes
18
+ - name: updated_at
19
+ type: timestamp
20
+ required: yes
21
+
22
+ tables:
23
+
24
+ - name: groups
25
+ desc: group master table
26
+ class: Group
27
+ columns:
28
+ - name: id
29
+ - name: name
30
+ - name: desc
31
+
32
+ - name: members
33
+ desc: member master table
34
+ class: Member
35
+ columns:
36
+ - name: id
37
+ - name: name
38
+ - name: desc
39
+ - name: email
40
+ type: str
41
+ width: 63
42
+ - name: gender
43
+ type: str
44
+ enum: [ M, W, X ]
45
+ - name: birth
46
+ type: date
47
+ - name: group_id
48
+ ref: groups.id
49
+ required: yes
50
+ - name: created_at
51
+ - name: updated_at
@@ -3,8 +3,8 @@
3
3
  ###
4
4
  ### RubyGems Specification file for Kwartz-ruby
5
5
  ###
6
- ### $Rev: 117 $
7
- ### $Release: 3.0.0 $
6
+ ### $Rev: 137 $
7
+ ### $Release: 3.1.0 $
8
8
  ### copyright(c) 2004-2006 kuwata-lab.com all rights reserved
9
9
  ###
10
10
 
@@ -14,7 +14,7 @@ spec = Gem::Specification.new do |s|
14
14
  ## package information
15
15
  s.name = 'kwartz'
16
16
  s.author = 'Makoto Kuwata'
17
- s.version = ("$Release: 3.0.0 $" =~ /[\.\d]+/) && $&
17
+ s.version = ("$Release: 3.1.0 $" =~ /[\.\d]+/) && $&
18
18
  s.platform = Gem::Platform::RUBY
19
19
  s.homepage = 'http://www.kuwata-lab.com/kwartz'
20
20
  s.summary = "a template system for Ruby, PHP, and Java"
@@ -41,7 +41,7 @@ spec = Gem::Specification.new do |s|
41
41
  #"doc/design.css", "doc/design.html",
42
42
  ]
43
43
  files += Dir.glob('doc-api/**/*')
44
- files += %w[README.txt ChangeLog COPYING setup.rb kwartz.gemspec]
44
+ files += %w[README.txt ChangeLog LGPL setup.rb kwartz.gemspec]
45
45
  s.files = files
46
46
  s.executables = ["kwartz"]
47
47
  s.bindir = "bin"
@@ -1,9 +1,16 @@
1
1
  ###
2
- ### $Rev: 103 $
3
- ### $Release: 3.0.0 $
2
+ ### $Rev: 136 $
3
+ ### $Release: 3.1.0 $
4
4
  ### copyright(c) 2004-2006 kuwata-lab.com all rights reserved
5
5
  ###
6
6
 
7
+
8
+ module Kwartz
9
+
10
+ RELEASE = ('$Release: 3.1.0 $' =~ /\$Release: (\S+)\s*\$/) && $1
11
+
12
+ end
13
+
7
14
  require 'kwartz/config'
8
15
  require 'kwartz/error'
9
16
  require 'kwartz/assert'
@@ -11,3 +18,4 @@ require 'kwartz/node'
11
18
  require 'kwartz/parser'
12
19
  require 'kwartz/converter'
13
20
  require 'kwartz/translator'
21
+ require 'kwartz/defun'
@@ -1,6 +1,6 @@
1
1
  ####
2
2
  #### $Rev: 103 $
3
- #### $Release: 3.0.0 $
3
+ #### $Release: 3.1.0 $
4
4
  #### copyright(c) 2004-2006 kuwata-lab.com all rights reserved
5
5
  ####
6
6
 
@@ -1,6 +1,6 @@
1
1
  ###
2
- ### $Rev: 117 $
3
- ### $Release: 3.0.0 $
2
+ ### $Rev: 123 $
3
+ ### $Release: 3.1.0 $
4
4
  ### copyright(c) 2004-2006 kuwata-lab.com all rights reserved
5
5
  ###
6
6
 
@@ -41,15 +41,16 @@ module Kwartz
41
41
  end
42
42
 
43
43
 
44
- def handle(directive_name, directive_arg, directive_str, stag_info, etag_info, cont_stmts, attr_info, append_exprs, stmt_list)
44
+ def handle(stmt_list, handler_arg)
45
45
  ret = super
46
46
  return ret if ret
47
47
 
48
- d_name = directive_name
49
- d_arg = directive_arg
50
- d_str = directive_str
48
+ arg = handler_arg
49
+ d_name = arg.directive_name
50
+ d_arg = arg.directive_arg
51
+ d_str = arg.directive_str
51
52
 
52
- case directive_name
53
+ case d_name
53
54
 
54
55
  when :foreach, :Foreach, :FOREACH, :list, :List, :LIST
55
56
  is_foreach = d_name == :foreach || d_name == :Foreach || d_name == :FOREACH
@@ -59,72 +60,95 @@ module Kwartz
59
60
  loopvar = $1 ; loopval = $2 ; looplist = $3
60
61
  counter = d_name == :foreach || d_name == :list ? nil : "#{loopvar}_ctr"
61
62
  toggle = d_name != :FOREACH && d_name != :LIST ? nil : "#{loopvar}_tgl"
62
- stmt_list << build_print_stmt(stag_info, attr_info, append_exprs) if !is_foreach
63
- stmt_list << NativeStatement.new("my #{counter} = 0;") if counter
63
+ code = []
64
+ code << "my #{counter} = 0;" if counter
64
65
  if loopval
65
- stmt_list << NativeStatement.new("foreach my #{loopvar} (keys #{looplist}) {", :foreach)
66
- stmt_list << NativeStatement.new(" my #{loopval} = #{looplist.sub(/\A%/,'$')}{#{loopvar}};")
66
+ code << "foreach my #{loopvar} (keys #{looplist}) {"
67
+ code << " my #{loopval} = #{looplist.sub(/\A%/,'$')}{#{loopvar}};"
67
68
  else
68
- stmt_list << NativeStatement.new("foreach my #{loopvar} (#{looplist}) {", :foreach)
69
+ code << "foreach my #{loopvar} (#{looplist}) {"
69
70
  end
70
- stmt_list << NativeStatement.new(" #{counter}++;") if counter
71
- stmt_list << NativeStatement.new(" my #{toggle} = #{counter}%2==0 ? #{self.even} : #{self.odd};") if toggle
72
- stmt_list << build_print_stmt(stag_info, attr_info, append_exprs) if is_foreach
73
- stmt_list.concat(cont_stmts)
74
- stmt_list << build_print_stmt(etag_info, nil, nil) if is_foreach
75
- stmt_list << NativeStatement.new("}", :foreach)
76
- stmt_list << build_print_stmt(etag_info, nil, nil) if !is_foreach
77
-
78
- when :while, :loop
79
- is_while = d_name == :while
80
- stmt_list << build_print_stmt(stag_info, attr_info, append_exprs) if !is_while
81
- stmt_list << NativeStatement.new("while (#{d_arg}) {", :while)
82
- stmt_list << build_print_stmt(stag_info, attr_info, append_exprs) if is_while
83
- stmt_list.concat(cont_stmts)
84
- stmt_list << build_print_stmt(etag_info, nil, nil) if is_while
85
- stmt_list << NativeStatement.new("}", :while)
86
- stmt_list << build_print_stmt(etag_info, nil, nil) if !is_while
71
+ code << " #{counter}++;" if counter
72
+ code << " my #{toggle} = #{counter}%2==0 ? #{self.even} : #{self.odd};" if toggle
73
+ if is_foreach
74
+ wrap_element_with_native_stmt(stmt_list, arg, code, "}", :foreach)
75
+ else
76
+ wrap_content_with_native_stmt(stmt_list, arg, code, "}", :foreach)
77
+ end
78
+ #stmt_list << stag_stmt(arg) if !is_foreach
79
+ #stmt_list << NativeStatement.new("my #{counter} = 0;") if counter
80
+ #if loopval
81
+ # stmt_list << NativeStatement.new("foreach my #{loopvar} (keys #{looplist}) {", :foreach)
82
+ # stmt_list << NativeStatement.new(" my #{loopval} = #{looplist.sub(/\A%/,'$')}{#{loopvar}};")
83
+ #else
84
+ # stmt_list << NativeStatement.new("foreach my #{loopvar} (#{looplist}) {", :foreach)
85
+ #end
86
+ #stmt_list << NativeStatement.new(" #{counter}++;") if counter
87
+ #stmt_list << NativeStatement.new(" my #{toggle} = #{counter}%2==0 ? #{self.even} : #{self.odd};") if toggle
88
+ #stmt_list << stag_stmt(arg) if is_foreach
89
+ #stmt_list.concat(arg.cont_stmts)
90
+ #stmt_list << etag_stmt(arg) if is_foreach
91
+ #stmt_list << NativeStatement.new("}", :foreach)
92
+ #stmt_list << etag_stmt(arg) if !is_foreach
93
+
94
+ when :while
95
+ wrap_element_with_native_stmt(stmt_list, arg, "while (#{d_arg}) {", "}", :while)
96
+ #stmt_list << NativeStatement.new("while (#{d_arg}) {", :while)
97
+ #stmt_list << stag_stmt(arg)
98
+ #stmt_list.concat(cont_stmts)
99
+ #stmt_list << etag_stmt(arg)
100
+ #stmt_list << NativeStatement.new("}", :while)
101
+
102
+ when :loop
103
+ error_if_empty_tag(arg)
104
+ wrap_content_with_native_stmt(stmt_list, arg, "while (#{d_arg}) {", "}", :while)
105
+ #stmt_list << stag_stmt
106
+ #stmt_list << NativeStatement.new("while (#{d_arg}) {", :while)
107
+ #stmt_list.concat(cont_stmts)
108
+ #stmt_list << NativeStatement.new("}", :while)
109
+ #stmt_list << etag_stmt
87
110
 
88
111
  when :set
89
- stmt_list << NativeStatement.new("#{d_arg};", :set)
90
- stmt_list << build_print_stmt(stag_info, attr_info, append_exprs)
91
- stmt_list.concat(cont_stmts)
92
- stmt_list << build_print_stmt(etag_info, nil, nil)
112
+ wrap_element_with_native_stmt(stmt_list, arg, "#{d_arg};", nil, :set)
113
+ #stmt_list << NativeStatement.new("#{d_arg};", :set)
114
+ #stmt_list << stag_stmt
115
+ #stmt_list.concat(cont_stmts)
116
+ #stmt_list << etag_stmt
93
117
 
94
118
  when :if
95
- stmt_list << NativeStatement.new("if (#{d_arg}) {", :if)
96
- stmt_list << build_print_stmt(stag_info, attr_info, append_exprs)
97
- stmt_list.concat(cont_stmts)
98
- stmt_list << build_print_stmt(etag_info, nil, nil)
99
- stmt_list << NativeStatement.new("}", :if)
119
+ wrap_element_with_native_stmt(stmt_list, arg, "if (#{d_arg}) {", "}", :if)
120
+ #stmt_list << NativeStatement.new("if (#{d_arg}) {", :if)
121
+ #stmt_list << stag_stmt
122
+ #stmt_list.concat(cont_stmts)
123
+ #stmt_list << etag_stmt
124
+ #stmt_list << NativeStatement.new("}", :if)
100
125
 
101
126
  when :elsif, :else
102
- unless !stmt_list.empty? && (st=stmt_list[-1]).is_a?(NativeStatement) && (st.kind == :if || st.kind == :elseif)
103
- raise convert_error("'#{d_str}': previous statement should be 'if' or 'elsif'.", stag_info.linenum)
104
- end
105
- stmt_list.pop # delete 'end'
106
- if d_name == :else
107
- kind = :else
108
- stmt_list << NativeStatement.new("} else {", :else)
109
- else
110
- kind = :elseif
111
- stmt_list << NativeStatement.new("} elsif (#{d_arg}) {", :elseif)
112
- end
113
- stmt_list << build_print_stmt(stag_info, attr_info, append_exprs)
114
- stmt_list.concat(cont_stmts)
115
- stmt_list << build_print_stmt(etag_info, nil, nil)
116
- stmt_list << NativeStatement.new("}", kind)
127
+ error_when_last_stmt_is_not_if(stmt_list, arg)
128
+ stmt_list.pop # delete '}'
129
+ kind = d_name == :else ? :else : :elseif
130
+ code = d_name == :else ? "} else {" : "} elsif (#{d_arg}) {"
131
+ wrap_element_with_native_stmt(stmt_list, arg, code, "}", kind)
132
+ #stmt_list << NativeStatement.new(code, kind)
133
+ #stmt_list << stag_stmt
134
+ #stmt_list.concat(cont_stmts)
135
+ #stmt_list << etag_stmt
136
+ #stmt_list << NativeStatement.new("}", kind)
117
137
 
118
138
  when :default, :Default, :DEFAULT
119
- error_if_empty_tag(stag_info, etag_info, d_name, d_arg)
120
- stmt_list << build_print_stmt(stag_info, attr_info, append_exprs)
121
- stmt_list << NativeStatement.new_without_newline("if (#{d_arg}) {", :if)
139
+ error_if_empty_tag(arg)
140
+ expr_code = d_arg
122
141
  flag_escape = d_name == :default ? nil : (d_name == :Default)
123
- stmt_list << PrintStatement.new([ NativeExpression.new(d_arg, flag_escape) ])
124
- stmt_list << NativeStatement.new_without_newline("} else {", :else)
125
- stmt_list.concat(cont_stmts)
126
- stmt_list << NativeStatement.new_without_newline("}", :else)
127
- stmt_list << build_print_stmt(etag_info, nil, nil)
142
+ add_native_expr_with_default(stmt_list, arg, expr_code, flag_escape,
143
+ "if (#{d_arg}) {", "} else {", "}")
144
+ #stmt_list << stag_stmt(arg)
145
+ #stmt_list << NativeStatement.new_without_newline("if (#{d_arg}) {", :if)
146
+ #flag_escape = d_name == :default ? nil : (d_name == :Default)
147
+ #stmt_list << PrintStatement.new([ NativeExpression.new(d_arg, flag_escape) ])
148
+ #stmt_list << NativeStatement.new_without_newline("} else {", :else)
149
+ #stmt_list.concat(arg.cont_stmts)
150
+ #stmt_list << NativeStatement.new_without_newline("}", :else)
151
+ #stmt_list << etag_stmt(arg)
128
152
 
129
153
  else
130
154
  return false
@@ -1,12 +1,12 @@
1
1
  ###
2
- ### $Rev: 110 $
3
- ### $Release: 3.0.0 $
2
+ ### $Rev: 124 $
3
+ ### $Release: 3.1.0 $
4
4
  ### copyright(c) 2004-2006 kuwata-lab.com all rights reserved
5
5
  ###
6
6
 
7
7
  require 'kwartz/converter'
8
8
  require 'kwartz/translator'
9
- require 'kwartz/binding/eruby'
9
+ require 'kwartz/binding/ruby'
10
10
 
11
11
 
12
12
 
@@ -14,10 +14,8 @@ module Kwartz
14
14
 
15
15
 
16
16
 
17
- class ErubisHandler < ErubyHandler
18
-
19
-
20
- end #class
17
+ class ErubisHandler < RubyHandler
18
+ end
21
19
  Handler.register_class('erubis', ErubisHandler)
22
20
 
23
21
 
@@ -37,7 +35,7 @@ module Kwartz
37
35
 
38
36
  def initialize(properties={})
39
37
  super(ERUBIS_EMBED_PATTERNS, properties)
40
- @escape = true if @escape == nil
38
+ #@escape = true if @escape == nil
41
39
  end
42
40
 
43
41