tenjin 0.6.2 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES.txt +163 -0
- data/MIT-LICENSE +16 -17
- data/README.txt +5 -5
- data/benchmark/Makefile +9 -0
- data/benchmark/bench.rb +3 -2
- data/bin/rbtenjin +6 -3
- data/doc/docstyle.css +25 -4
- data/doc/users-guide.html +2088 -1563
- data/lib/tenjin.rb +784 -158
- data/public_html/_layout.rbhtml +33 -0
- data/public_html/css/style.css +77 -0
- data/public_html/env.rbhtml +15 -0
- data/public_html/favicon.ico +0 -0
- data/public_html/hello.rbhtml +14 -0
- data/public_html/index.rbhtml +39 -0
- data/public_html/rbtenjin.cgi +188 -0
- data/tenjin.gemspec +9 -6
- data/test/data/examples/preprocessing/main.rb +1 -1
- data/test/data/examples/preprocessing/select.rbhtml +1 -1
- data/test/data/faq/{ex11-bench.rb → ex10-bench.rb} +3 -3
- data/test/data/faq/ex10-content.rbhtml +8 -11
- data/test/data/faq/{ex11-layout1.rbhtml → ex10-layout1.rbhtml} +0 -0
- data/test/data/faq/{ex11-layout2.rbhtml → ex10-layout2.rbhtml} +0 -0
- data/test/data/faq/{ex11.rb → ex10.rb} +1 -1
- data/test/data/faq/{ex11.rbhtml → ex10.rbhtml} +0 -0
- data/test/data/faq/{ex11.source → ex10.source} +2 -2
- data/test/data/faq/{ex11_arraybuffer.result → ex10_arraybuffer.result} +1 -1
- data/test/data/faq/{ex5.rbhtml → ex2.rbhtml} +0 -0
- data/test/data/faq/{ex5_template_args.source → ex2_template_args.source} +1 -1
- data/test/data/faq/{ex7-expr-pattern.rb → ex4-expr-pattern.rb} +1 -1
- data/test/data/faq/{ex7-expr-pattern.rbhtml → ex4-expr-pattern.rbhtml} +0 -0
- data/test/data/faq/{ex7_expr_pattern.result → ex4_expr_pattern.result} +1 -1
- data/test/data/faq/{ex6-content.rhtml → ex5-content.rhtml} +0 -0
- data/test/data/faq/{ex6-layout.rhtml → ex5-layout.rhtml} +0 -0
- data/test/data/faq/{ex6.rb → ex5.rb} +2 -2
- data/test/data/faq/{ex6_eruby.result → ex5_eruby.result} +1 -1
- data/test/data/faq/{ex2-content.rbhtml → ex6-content.rbhtml} +0 -0
- data/test/data/faq/{ex2-layout.rbhtml → ex6-layout.rbhtml} +0 -0
- data/test/data/faq/{ex2_removenl.result → ex6_removenl.result} +1 -1
- data/test/data/faq/ex7-m18n.rb +48 -0
- data/test/data/faq/{ex8-m18n.rbhtml → ex7-m18n.rbhtml} +0 -0
- data/test/data/faq/{ex8_m18n.result → ex7_m18n.result} +1 -1
- data/test/data/faq/ex8-baselayout.rbhtml +8 -0
- data/test/data/faq/ex8-content.rbhtml +6 -0
- data/test/data/faq/{ex9-mylayout.rbhtml → ex8-mylayout.rbhtml} +0 -0
- data/test/data/faq/{ex9_changelayout.result → ex8_changelayout.result} +1 -1
- data/test/data/faq/ex9-baselayout.rbhtml +24 -5
- data/test/data/faq/ex9-content.rbhtml +12 -6
- data/test/data/faq/{ex10-customlayout.rbhtml → ex9-customlayout.rbhtml} +1 -1
- data/test/data/faq/{ex10_inherit.result → ex9_inherit.result} +1 -1
- data/test/data/faq/helpers1.rb +17 -0
- data/test/data/faq/helpers1.rbhtml +4 -0
- data/test/data/faq/helpers1.result +11 -0
- data/test/data/faq/helpers2.rb +21 -0
- data/test/data/faq/helpers2.rbhtml +4 -0
- data/test/data/faq/helpers2.result +11 -0
- data/test/data/faq/weekday1.rb +6 -0
- data/test/data/faq/weekday1.rbhtml +9 -0
- data/test/data/faq/weekday1.result +23 -0
- data/test/data/faq/weekday2.rb +8 -0
- data/test/data/faq/weekday2.rbhtml +10 -0
- data/test/data/faq/weekday2.result +24 -0
- data/test/data/faq/weekday3.rb +22 -0
- data/test/data/faq/weekday3.rbhtml +3 -0
- data/test/data/faq/weekday3.result +28 -0
- data/test/data/users_guide/test_010/main.rb +14 -0
- data/test/data/users_guide/test_010/result.output +13 -0
- data/test/data/users_guide/test_010/views/page.rbhtml +11 -0
- data/test/data/users_guide/test_011/main.rb +14 -0
- data/test/data/users_guide/test_011/result.output +2 -0
- data/test/data/users_guide/test_011/views/page.rbhtml +11 -0
- data/test/data/users_guide/test_020/main.rb +14 -0
- data/test/data/users_guide/test_020/result.output +13 -0
- data/test/data/users_guide/test_020/views/page.rbhtml +11 -0
- data/test/data/users_guide/test_021/main.rb +12 -0
- data/test/data/users_guide/test_021/result.output +12 -0
- data/test/data/users_guide/test_021/views/page.rbhtml +11 -0
- data/test/data/users_guide/test_030/main.rb +14 -0
- data/test/data/users_guide/test_030/result.output +23 -0
- data/test/data/users_guide/test_030/views/_layout.rbhtml +10 -0
- data/test/data/users_guide/test_030/views/page.rbhtml +11 -0
- data/test/data/users_guide/test_040/main.rb +14 -0
- data/test/data/users_guide/test_040/result.output +23 -0
- data/test/data/users_guide/test_040/views/_layout.rbhtml +10 -0
- data/test/data/users_guide/test_040/views/page.rbhtml +12 -0
- data/test/data/users_guide/test_050/main.rb +14 -0
- data/test/data/users_guide/test_050/result.output +14 -0
- data/test/data/users_guide/test_050/views/_layout.rbhtml +10 -0
- data/test/data/users_guide/test_050/views/page.rbhtml +13 -0
- data/test/data/users_guide/test_051/main.rb +14 -0
- data/test/data/users_guide/test_051/result.output +12 -0
- data/test/data/users_guide/test_051/views/_layout.rbhtml +11 -0
- data/test/data/users_guide/test_051/views/page.rbhtml +13 -0
- data/test/data/users_guide/test_060/main.rb +14 -0
- data/test/data/users_guide/test_060/result.output +29 -0
- data/test/data/users_guide/test_060/views/_footer.rbhtml +3 -0
- data/test/data/users_guide/test_060/views/_header.rbhtml +3 -0
- data/test/data/users_guide/test_060/views/_layout.rbhtml +13 -0
- data/test/data/users_guide/test_060/views/page.rbhtml +13 -0
- data/test/data/users_guide/test_070/main.rb +14 -0
- data/test/data/users_guide/test_070/result.output +29 -0
- data/test/data/users_guide/test_070/views/_footer.rbhtml +3 -0
- data/test/data/users_guide/test_070/views/_header.rbhtml +3 -0
- data/test/data/users_guide/test_070/views/_layout.rbhtml +13 -0
- data/test/data/users_guide/test_070/views/page.rbhtml +13 -0
- data/test/data/users_guide/test_capturing/main.rb +24 -0
- data/test/data/users_guide/test_capturing/result.output +28 -0
- data/test/data/users_guide/test_capturing/views/_layout.rbhtml +21 -0
- data/test/data/users_guide/test_capturing/views/blog-post.rbhtml +13 -0
- data/test/data/users_guide/test_context/context.rb +5 -0
- data/test/data/users_guide/test_context/context.yaml +4 -0
- data/test/data/users_guide/test_context/example.rbhtml +5 -0
- data/test/data/users_guide/test_context/result1.output +6 -0
- data/test/data/users_guide/test_context/result2.output +6 -0
- data/test/data/users_guide/test_context/result3.output +6 -0
- data/test/data/users_guide/test_context/result4.output +6 -0
- data/test/data/users_guide/test_convert/example.rbhtml +5 -0
- data/test/data/users_guide/test_convert/result1.output +7 -0
- data/test/data/users_guide/test_convert/result2.output +6 -0
- data/test/data/users_guide/test_escape/main.rb +4 -0
- data/test/data/users_guide/test_escape/result.output +5 -0
- data/test/data/users_guide/test_escape/views/page.rbhtml +4 -0
- data/test/data/users_guide/test_execute/example.rbhtml +6 -0
- data/test/data/users_guide/test_execute/result.output +6 -0
- data/test/data/users_guide/test_fragmentcache/cache.d/items/1 +5 -0
- data/test/data/users_guide/test_fragmentcache/main.rb +21 -0
- data/test/data/users_guide/test_fragmentcache/result.output +8 -0
- data/test/data/users_guide/test_fragmentcache/result2.output +6 -0
- data/test/data/users_guide/test_fragmentcache/views/items.rbhtml +10 -0
- data/test/data/users_guide/test_logging/ex-logger.rb +11 -0
- data/test/data/users_guide/test_logging/example.rbhtml +0 -0
- data/test/data/users_guide/test_logging/result1.output +3 -0
- data/test/data/users_guide/test_logging/result2.output +2 -0
- data/test/data/users_guide/test_m17n/m17n.rb +44 -0
- data/test/data/users_guide/test_m17n/m17n.rbhtml +5 -0
- data/test/data/users_guide/test_m17n/result.output +9 -0
- data/test/data/users_guide/test_m17n/result_en.output +4 -0
- data/test/data/users_guide/test_m17n/result_fr.output +4 -0
- data/test/data/users_guide/test_nested/main.rb +8 -0
- data/test/data/users_guide/test_nested/result.output +15 -0
- data/test/data/users_guide/test_nested/views/_blog_layout.rbhtml +5 -0
- data/test/data/users_guide/{layout8_html.rbhtml → test_nested/views/_site_layout.rbhtml} +0 -0
- data/test/data/users_guide/test_nested/views/blog_post.rbhtml +4 -0
- data/test/data/users_guide/test_preprocessing/pp-example1.rb +14 -0
- data/test/data/users_guide/test_preprocessing/result1a.output +11 -0
- data/test/data/users_guide/test_preprocessing/result1b.output +5 -0
- data/test/data/users_guide/test_preprocessing/result1c.output +6 -0
- data/test/data/users_guide/test_preprocessing/result2a.output +10 -0
- data/test/data/users_guide/test_preprocessing/result2b.output +10 -0
- data/test/data/users_guide/test_preprocessing/result3a.output +2 -0
- data/test/data/users_guide/test_preprocessing/result3b.output +2 -0
- data/test/data/users_guide/test_preprocessing/views/pp-example1.rbhtml +4 -0
- data/test/data/users_guide/{example12.rbhtml → test_preprocessing/views/pp-example2.rbhtml} +4 -4
- data/test/data/users_guide/test_preprocessing/views/pp-example3.rbhtml +7 -0
- data/test/data/users_guide/test_retrieve/example.rbhtml +10 -0
- data/test/data/users_guide/test_retrieve/result1.output +11 -0
- data/test/data/users_guide/test_retrieve/result2.output +11 -0
- data/test/data/users_guide/test_retrieve/result3.output +11 -0
- data/test/data/users_guide/test_retrieve/result4.output +8 -0
- data/test/data/users_guide/test_retrieve/result5.output +5 -0
- data/test/data/users_guide/test_safe/result.output +6 -0
- data/test/data/users_guide/test_safe/safe-test.rb +21 -0
- data/test/data/users_guide/test_safehelper/main.rb +16 -0
- data/test/data/users_guide/test_safehelper/result.output +8 -0
- data/test/data/users_guide/{example3.rbhtml → test_syntax_check/example.rbhtml} +0 -0
- data/test/data/users_guide/test_syntax_check/result.output +2 -0
- data/test/data/users_guide/test_trace/layout.rbhtml +7 -0
- data/test/data/users_guide/test_trace/main.rbhtml +5 -0
- data/test/data/users_guide/test_trace/result.output +16 -0
- data/test/data/users_guide/test_trace/trace-example.rb +4 -0
- data/test/oktest.rb +755 -0
- data/test/test_all.rb +24 -14
- data/test/test_engine.rb +628 -63
- data/test/test_engine.yaml +40 -3
- data/test/test_examples.rb +14 -12
- data/test/test_faq.rb +17 -12
- data/test/test_htmlhelper.rb +104 -33
- data/test/test_main.rb +32 -21
- data/test/test_main.yaml +2 -2
- data/test/test_safe.rb +206 -0
- data/test/test_store.rb +220 -0
- data/test/test_tcache.rb +94 -0
- data/test/test_template.rb +65 -23
- data/test/test_template.yaml +7 -7
- data/test/test_users_guide.rb +75 -29
- data/test/testcase-helper.rb +20 -18
- data/test/testunit-assertions.rb +71 -0
- metadata +185 -159
- data/doc-api/classes/Tenjin.html +0 -141
- data/doc-api/classes/Tenjin/ArrayBufferTemplate.html +0 -270
- data/doc-api/classes/Tenjin/BaseContext.html +0 -329
- data/doc-api/classes/Tenjin/Context.html +0 -126
- data/doc-api/classes/Tenjin/ContextHelper.html +0 -461
- data/doc-api/classes/Tenjin/Engine.html +0 -616
- data/doc-api/classes/Tenjin/ErubisTemplate.html +0 -166
- data/doc-api/classes/Tenjin/HtmlHelper.html +0 -359
- data/doc-api/classes/Tenjin/Preprocessor.html +0 -242
- data/doc-api/classes/Tenjin/Template.html +0 -916
- data/doc-api/created.rid +0 -1
- data/doc-api/files/README_txt.html +0 -188
- data/doc-api/files/lib/tenjin_rb.html +0 -136
- data/doc-api/fr_class_index.html +0 -36
- data/doc-api/fr_file_index.html +0 -28
- data/doc-api/fr_method_index.html +0 -91
- data/doc-api/index.html +0 -24
- data/doc-api/rdoc-style.css +0 -208
- data/doc/examples.html +0 -312
- data/doc/faq.html +0 -909
- data/examples/preprocessing/select.rbhtml.cache +0 -17
- data/test/Rookbook.yaml +0 -14
- data/test/assert-text-equal.rb +0 -45
- data/test/data/faq/ex10-baselayout.rbhtml +0 -27
- data/test/data/faq/ex11-content.rbhtml +0 -9
- data/test/data/faq/ex8-m18n.rb +0 -77
- data/test/data/users_guide/content6.rbhtml +0 -3
- data/test/data/users_guide/content7.rbhtml +0 -5
- data/test/data/users_guide/content8.rbhtml +0 -2
- data/test/data/users_guide/contextdata.rb +0 -7
- data/test/data/users_guide/datafile.rb +0 -5
- data/test/data/users_guide/datafile.yaml +0 -10
- data/test/data/users_guide/ex.rbhtml +0 -6
- data/test/data/users_guide/ex.result +0 -7
- data/test/data/users_guide/ex.script +0 -5
- data/test/data/users_guide/ex_script.result +0 -7
- data/test/data/users_guide/ex_source.result +0 -8
- data/test/data/users_guide/example1.rbhtml +0 -12
- data/test/data/users_guide/example1.result +0 -17
- data/test/data/users_guide/example10.rbhtml +0 -4
- data/test/data/users_guide/example10_template_args.result +0 -6
- data/test/data/users_guide/example11.rbhtml +0 -5
- data/test/data/users_guide/example11_template_args_result +0 -2
- data/test/data/users_guide/example12_preprocessed.result +0 -10
- data/test/data/users_guide/example12_preprocessed_source.result +0 -10
- data/test/data/users_guide/example13.rbhtml +0 -6
- data/test/data/users_guide/example13_preprocessed.result +0 -2
- data/test/data/users_guide/example13_preprocessed_source.result +0 -2
- data/test/data/users_guide/example14.rb +0 -32
- data/test/data/users_guide/example14.rbhtml +0 -6
- data/test/data/users_guide/example14_tmplclass.result +0 -15
- data/test/data/users_guide/example15.rb +0 -10
- data/test/data/users_guide/example15_escapefunc.result +0 -14
- data/test/data/users_guide/example16.rbhtml +0 -4
- data/test/data/users_guide/example16a.rb +0 -10
- data/test/data/users_guide/example16a.result +0 -4
- data/test/data/users_guide/example16b.rb +0 -13
- data/test/data/users_guide/example16b.result +0 -4
- data/test/data/users_guide/example16c.rb +0 -12
- data/test/data/users_guide/example16c.result +0 -4
- data/test/data/users_guide/example16d.rb +0 -27
- data/test/data/users_guide/example16d.result +0 -4
- data/test/data/users_guide/example1_S.result +0 -14
- data/test/data/users_guide/example1_SXNC.result +0 -10
- data/test/data/users_guide/example1_source.result +0 -14
- data/test/data/users_guide/example2.rbhtml +0 -3
- data/test/data/users_guide/example2_sb.result2 +0 -9
- data/test/data/users_guide/example3_syntaxcheck.result +0 -2
- data/test/data/users_guide/example4.rbhtml +0 -13
- data/test/data/users_guide/example4_datafile_rb.result +0 -13
- data/test/data/users_guide/example4_yaml.result +0 -13
- data/test/data/users_guide/example5.rbhtml +0 -9
- data/test/data/users_guide/example5_datastr_rb.result +0 -9
- data/test/data/users_guide/example5_datastr_yaml.result +0 -9
- data/test/data/users_guide/example6.rbhtml +0 -19
- data/test/data/users_guide/example6_layout.result +0 -29
- data/test/data/users_guide/example6_nested.result +0 -28
- data/test/data/users_guide/example7_layout2.result +0 -13
- data/test/data/users_guide/example8_layout3.result +0 -8
- data/test/data/users_guide/example9.rbhtml +0 -18
- data/test/data/users_guide/example9_capture.result +0 -26
- data/test/data/users_guide/footer.html +0 -5
- data/test/data/users_guide/footer.rbhtml +0 -4
- data/test/data/users_guide/layout6.rbhtml +0 -17
- data/test/data/users_guide/layout7.rbhtml +0 -9
- data/test/data/users_guide/layout8_xhtml.rbhtml +0 -6
- data/test/data/users_guide/layout9.rbhtml +0 -25
- data/test/data/users_guide/sidemenu.rbhtml +0 -5
- data/test/data/users_guide/user_app.cgi +0 -39
- data/test/data/users_guide/user_app.result +0 -30
- data/test/data/users_guide/user_create.rbhtml +0 -6
- data/test/data/users_guide/user_edit.rbhtml +0 -7
- data/test/data/users_guide/user_form.rbhtml +0 -10
- data/test/data/users_guide/user_layout.rbhtml +0 -16
data/test/test_engine.yaml
CHANGED
@@ -1188,7 +1188,7 @@
|
|
1188
1188
|
"python": |
|
1189
1189
|
<html>
|
1190
1190
|
<body>
|
1191
|
-
<?py if
|
1191
|
+
<?py if 'title' in _context: ?>
|
1192
1192
|
<h1>${title}</h1>
|
1193
1193
|
<?py #end ?>
|
1194
1194
|
<?py _buf.append(_content) ?>
|
@@ -1401,7 +1401,7 @@
|
|
1401
1401
|
"js": |
|
1402
1402
|
errormsg*:
|
1403
1403
|
"python": name 'b' is not defined
|
1404
|
-
"ruby": "undefined local variable or method `b' for #<Tenjin::Context>"
|
1404
|
+
"ruby": "undefined local variable or method `b' for #<Tenjin::Context:0x12345>"
|
1405
1405
|
"perl": |
|
1406
1406
|
*** Error: content.plhtml
|
1407
1407
|
Global symbol "$y" requires explicit package name at (eval 999) line 3.
|
@@ -1799,7 +1799,7 @@
|
|
1799
1799
|
<?PY "FL": "Florida", } ?>
|
1800
1800
|
<?PY # ?>
|
1801
1801
|
<?py chk = { params['state']: ' checked="checked"' } ?>
|
1802
|
-
<?PY codes = states.keys() ?>
|
1802
|
+
<?PY codes = list(states.keys()) ?>
|
1803
1803
|
<?PY codes.sort() ?>
|
1804
1804
|
<select name="state">
|
1805
1805
|
<option value="">-</option>
|
@@ -2037,3 +2037,40 @@
|
|
2037
2037
|
<input type="submit" value=""Update"">\n\
|
2038
2038
|
</form>\n');
|
2039
2039
|
_buf.join('')
|
2040
|
+
|
2041
|
+
|
2042
|
+
- name: test_include_with_preprocess
|
2043
|
+
testopts: { preprocess: true }
|
2044
|
+
index_html*:
|
2045
|
+
"python": |
|
2046
|
+
## TODO (index.pyhtml)
|
2047
|
+
"ruby": |
|
2048
|
+
<?rb @val = 10 ?>
|
2049
|
+
<?rb import "show.rbhtml" ?>
|
2050
|
+
<?rb @val = 20 ?>
|
2051
|
+
<?rb import "show.rbhtml" ?>
|
2052
|
+
<?rb @val = 30 ?>
|
2053
|
+
<?rb import "show.rbhtml" ?>
|
2054
|
+
"perl": |
|
2055
|
+
## TODO (index.plhtml)
|
2056
|
+
"js": |
|
2057
|
+
## TODO (index.jshtml)
|
2058
|
+
"php": |
|
2059
|
+
## TODO (index.phphtml)
|
2060
|
+
|
2061
|
+
show_html*:
|
2062
|
+
"python": |
|
2063
|
+
## TODO (show.pyhtml)
|
2064
|
+
"ruby": |
|
2065
|
+
value is #{@val}
|
2066
|
+
"perl": |
|
2067
|
+
## TODO (show.plhtml)
|
2068
|
+
"js": |
|
2069
|
+
## TODO (show.jshtml)
|
2070
|
+
"php": |
|
2071
|
+
## TODO (show.phphtml)
|
2072
|
+
|
2073
|
+
expected: |
|
2074
|
+
value is 10
|
2075
|
+
value is 20
|
2076
|
+
value is 30
|
data/test/test_examples.rb
CHANGED
@@ -1,13 +1,10 @@
|
|
1
1
|
###
|
2
|
-
### $Rev
|
3
|
-
### $Release: 0.
|
4
|
-
### copyright(c) 2007-
|
2
|
+
### $Rev$
|
3
|
+
### $Release: 0.7.0 $
|
4
|
+
### copyright(c) 2007-2011 kuwata-lab.com all rights reserved
|
5
5
|
###
|
6
6
|
|
7
|
-
require
|
8
|
-
#require 'testutil'
|
9
|
-
#require 'testcase-helper'
|
10
|
-
require 'assert-text-equal'
|
7
|
+
require "#{File.dirname(File.expand_path(__FILE__))}/test_all"
|
11
8
|
|
12
9
|
#class Symbol
|
13
10
|
# def <=>(other)
|
@@ -24,20 +21,20 @@ require 'assert-text-equal'
|
|
24
21
|
# end
|
25
22
|
#end
|
26
23
|
|
27
|
-
require 'tenjin'
|
28
24
|
|
29
|
-
class TenjinExamplesTest
|
25
|
+
class TenjinExamplesTest
|
26
|
+
include Oktest::TestCase
|
30
27
|
|
31
28
|
DIR = File.expand_path(File.dirname(__FILE__) + '/data/examples')
|
32
29
|
CWD = Dir.pwd()
|
33
30
|
|
34
31
|
|
35
|
-
def
|
32
|
+
def before
|
36
33
|
Dir.chdir DIR
|
37
34
|
end
|
38
35
|
|
39
36
|
|
40
|
-
def
|
37
|
+
def after
|
41
38
|
Dir.chdir CWD
|
42
39
|
end
|
43
40
|
|
@@ -55,7 +52,7 @@ class TenjinExamplesTest < Test::Unit::TestCase
|
|
55
52
|
command = $1
|
56
53
|
expected = $'
|
57
54
|
result = `#{command}`
|
58
|
-
|
55
|
+
ok_(result) == expected
|
59
56
|
end
|
60
57
|
|
61
58
|
|
@@ -79,3 +76,8 @@ class TenjinExamplesTest < Test::Unit::TestCase
|
|
79
76
|
|
80
77
|
|
81
78
|
end
|
79
|
+
|
80
|
+
|
81
|
+
if __FILE__ == $0
|
82
|
+
Oktest.run_all()
|
83
|
+
end
|
data/test/test_faq.rb
CHANGED
@@ -1,28 +1,25 @@
|
|
1
1
|
###
|
2
|
-
### $Rev
|
3
|
-
### $Release: 0.
|
4
|
-
### copyright(c) 2007-
|
2
|
+
### $Rev$
|
3
|
+
### $Release: 0.7.0 $
|
4
|
+
### copyright(c) 2007-2011 kuwata-lab.com all rights reserved
|
5
5
|
###
|
6
6
|
|
7
|
-
require
|
8
|
-
#require 'testutil'
|
9
|
-
#require 'testcase-helper'
|
10
|
-
require 'assert-text-equal'
|
7
|
+
require "#{File.dirname(File.expand_path(__FILE__))}/test_all"
|
11
8
|
|
12
|
-
require 'tenjin'
|
13
9
|
|
14
|
-
class TenjinFaqTest
|
10
|
+
class TenjinFaqTest
|
11
|
+
include Oktest::TestCase
|
15
12
|
|
16
13
|
DIR = File.expand_path(File.dirname(__FILE__) + '/data/faq')
|
17
14
|
CWD = Dir.pwd()
|
18
15
|
|
19
16
|
|
20
|
-
def
|
17
|
+
def before
|
21
18
|
Dir.chdir DIR
|
22
19
|
end
|
23
20
|
|
24
21
|
|
25
|
-
def
|
22
|
+
def after
|
26
23
|
Dir.chdir CWD
|
27
24
|
end
|
28
25
|
|
@@ -33,8 +30,11 @@ class TenjinFaqTest < Test::Unit::TestCase
|
|
33
30
|
s =~ /\A\$ (.*?)\n/
|
34
31
|
command = $1
|
35
32
|
expected = $'
|
33
|
+
if RUBY_VERSION >= '1.9'
|
34
|
+
expected.gsub!(/(expecting|unexpected) kEND/, '\1 keyword_end')
|
35
|
+
end
|
36
36
|
result = `#{command}`
|
37
|
-
|
37
|
+
ok_(result) == expected
|
38
38
|
end
|
39
39
|
|
40
40
|
|
@@ -58,3 +58,8 @@ class TenjinFaqTest < Test::Unit::TestCase
|
|
58
58
|
|
59
59
|
|
60
60
|
end
|
61
|
+
|
62
|
+
|
63
|
+
if __FILE__ == $0
|
64
|
+
Oktest.run_all()
|
65
|
+
end
|
data/test/test_htmlhelper.rb
CHANGED
@@ -1,78 +1,149 @@
|
|
1
1
|
###
|
2
|
-
### $Rev
|
3
|
-
### $Release: 0.
|
4
|
-
### copyright(c) 2007-
|
2
|
+
### $Rev$
|
3
|
+
### $Release: 0.7.0 $
|
4
|
+
### copyright(c) 2007-2011 kuwata-lab.com all rights reserved
|
5
5
|
###
|
6
6
|
|
7
|
-
require
|
8
|
-
#require 'testutil'
|
9
|
-
require 'testcase-helper'
|
10
|
-
require 'assert-text-equal'
|
11
|
-
require 'tenjin'
|
7
|
+
require "#{File.dirname(File.expand_path(__FILE__))}/test_all"
|
12
8
|
|
13
9
|
|
14
|
-
class TenjinHtmlHelperTest
|
10
|
+
class TenjinHtmlHelperTest
|
11
|
+
include Oktest::TestCase
|
12
|
+
include Tenjin::ContextHelper
|
13
|
+
include Tenjin::HtmlHelper
|
14
|
+
include Tenjin::HtmlTagHelper
|
15
|
+
include Tenjin::SafeHelper
|
16
|
+
|
17
|
+
def test_escape_xml
|
18
|
+
ok_(escape_xml('<>&"\'')) == '<>&"\''
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_escape_html
|
22
|
+
ok_(escape_html('<>&"\'')) == '<>&"''
|
23
|
+
end
|
15
24
|
|
16
25
|
def test_tagattr
|
17
|
-
actual =
|
26
|
+
actual = tagattr('size', 20)
|
18
27
|
expected = ' size="20"'
|
19
|
-
|
28
|
+
ok_(actual) == expected
|
20
29
|
#
|
21
|
-
actual =
|
30
|
+
actual = tagattr('size', nil)
|
22
31
|
expected = ''
|
23
|
-
|
32
|
+
ok_(actual) == expected
|
24
33
|
#
|
25
|
-
actual =
|
34
|
+
actual = tagattr('checked', true, 'checked')
|
26
35
|
expected = ' checked="checked"'
|
27
|
-
|
36
|
+
ok_(actual) == expected
|
28
37
|
#
|
29
|
-
actual =
|
38
|
+
actual = tagattr('checked', false, 'checked')
|
30
39
|
expected = ''
|
31
|
-
|
40
|
+
ok_(actual) == expected
|
41
|
+
#
|
42
|
+
spec "return SafeString object." do
|
43
|
+
ok_(tagattr('size', 20)).is_a?(Tenjin::SafeString)
|
44
|
+
end
|
32
45
|
end
|
33
46
|
|
34
47
|
def test_checked
|
35
|
-
actual =
|
48
|
+
actual = checked(1==1)
|
36
49
|
expected = ' checked="checked"'
|
37
|
-
|
50
|
+
ok_(actual) == expected
|
38
51
|
#
|
39
|
-
actual =
|
52
|
+
actual = checked(1==0)
|
40
53
|
expected = ''
|
41
|
-
|
54
|
+
ok_(actual) == expected
|
55
|
+
#
|
56
|
+
spec "return SafeString object." do
|
57
|
+
ok_(checked(1==1)).is_a?(Tenjin::SafeString)
|
58
|
+
end
|
42
59
|
end
|
43
60
|
|
44
61
|
def test_selected
|
45
|
-
actual =
|
62
|
+
actual = selected(1==1)
|
46
63
|
expected = ' selected="selected"'
|
47
|
-
|
64
|
+
ok_(actual) == expected
|
48
65
|
#
|
49
|
-
actual =
|
66
|
+
actual = selected(1==0)
|
50
67
|
expected = ''
|
51
|
-
|
68
|
+
ok_(actual) == expected
|
69
|
+
#
|
70
|
+
spec "return SafeString object." do
|
71
|
+
ok_(selected(1==1)).is_a?(Tenjin::SafeString)
|
72
|
+
end
|
52
73
|
end
|
53
74
|
|
54
75
|
def test_disabled
|
55
|
-
actual =
|
76
|
+
actual = disabled(1==1)
|
56
77
|
expected = ' disabled="disabled"'
|
57
|
-
|
78
|
+
ok_(actual) == expected
|
58
79
|
#
|
59
|
-
actual =
|
80
|
+
actual = disabled(1==0)
|
60
81
|
expected = ''
|
61
|
-
|
82
|
+
ok_(actual) == expected
|
83
|
+
#
|
84
|
+
spec "return SafeString object." do
|
85
|
+
ok_(disabled(1==1)).is_a?(Tenjin::SafeString)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def test_nv
|
90
|
+
## generates 'name="..." value="..."' string
|
91
|
+
ok_(nv('user', 'guest')) == ' name="user" value="guest"'
|
92
|
+
## nil is converted into empty string
|
93
|
+
ok_(nv('user', nil)) == ' name="user" value=""'
|
94
|
+
ok_(nv(nil, 'guest')) == ' name="" value="guest"'
|
95
|
+
## escapes both name and value attrigute
|
96
|
+
ok_(nv('<user>', '<guest>')) == ' name="<user>" value="<guest>"'
|
97
|
+
## if separator is passed then id attribute is added
|
98
|
+
ok_(nv('user', 'guest', '-')) == ' name="user" value="guest" id="user-guest"'
|
99
|
+
end
|
100
|
+
|
101
|
+
def test_js_link
|
102
|
+
## generates '<a href="" onclick=""></a>'
|
103
|
+
ok_(js_link('Show', '$().show()')) == \
|
104
|
+
'<a href="javascript:undefined" onclick="$().show();return false">Show</a>'
|
105
|
+
## accepts extra tag name and value
|
106
|
+
ok_(js_link('Show', "$().show()", :class=>"link")) == \
|
107
|
+
'<a href="javascript:undefined" onclick="$().show();return false" class="link">Show</a>'
|
108
|
+
## escapes js code and label
|
109
|
+
ok_(js_link('Tiger&Bunny', 'alert("tiger&bunny")')) == \
|
110
|
+
'<a href="javascript:undefined" onclick="alert("tiger&bunny");return false">Tiger&Bunny</a>'
|
62
111
|
end
|
63
112
|
|
64
113
|
def test_nl2br
|
65
114
|
s = """foo\nbar\nbaz\n"""
|
66
|
-
actual =
|
115
|
+
actual = nl2br(s)
|
67
116
|
expected = "foo<br />\nbar<br />\nbaz<br />\n"
|
68
|
-
|
117
|
+
ok_(actual) == expected
|
118
|
+
#
|
119
|
+
spec "return SafeString object." do
|
120
|
+
ok_(actual).is_a?(Tenjin::SafeString)
|
121
|
+
end
|
69
122
|
end
|
70
123
|
|
71
124
|
def test_text2html
|
72
125
|
s = """foo\n bar\nba z\n"""
|
73
|
-
actual =
|
126
|
+
actual = text2html(s)
|
74
127
|
expected = "foo<br />\n bar<br />\nba z<br />\n"
|
75
|
-
|
128
|
+
ok_(actual) == expected
|
129
|
+
#
|
130
|
+
spec "return SafeString object." do
|
131
|
+
ok_(actual).is_a?(Tenjin::SafeString)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
def test_Cycle
|
136
|
+
cycle = Cycle.new('odd', 'even')
|
137
|
+
ok_("#{cycle}") == 'odd'
|
138
|
+
ok_("#{cycle}") == 'even'
|
139
|
+
ok_("#{cycle}") == 'odd'
|
140
|
+
ok_("#{cycle}") == 'even'
|
76
141
|
end
|
77
142
|
|
143
|
+
|
144
|
+
end
|
145
|
+
|
146
|
+
|
147
|
+
if __FILE__ == $0
|
148
|
+
Oktest.run_all()
|
78
149
|
end
|
data/test/test_main.rb
CHANGED
@@ -1,15 +1,11 @@
|
|
1
1
|
###
|
2
|
-
### $Rev
|
3
|
-
### $Release: 0.
|
4
|
-
### copyright(c) 2007-
|
2
|
+
### $Rev$
|
3
|
+
### $Release: 0.7.0 $
|
4
|
+
### copyright(c) 2007-2011 kuwata-lab.com all rights reserved
|
5
5
|
###
|
6
6
|
|
7
|
-
require
|
8
|
-
#require 'testutil'
|
9
|
-
require 'testcase-helper'
|
10
|
-
require 'assert-text-equal'
|
7
|
+
require "#{File.dirname(File.expand_path(__FILE__))}/test_all"
|
11
8
|
|
12
|
-
require 'tenjin'
|
13
9
|
DONT_INVOKE = true
|
14
10
|
load File.dirname(File.dirname(File.expand_path(__FILE__))) + '/bin/rbtenjin'
|
15
11
|
|
@@ -88,7 +84,7 @@ OUTPUT = <<'END'
|
|
88
84
|
<li><a&b>
|
89
85
|
<a&b></li>
|
90
86
|
<li>["c",'d']
|
91
|
-
["c"
|
87
|
+
["c",'d']</li>
|
92
88
|
</ul>
|
93
89
|
END
|
94
90
|
|
@@ -97,7 +93,7 @@ OUTPUT2 = <<'END'
|
|
97
93
|
<li><a&b>
|
98
94
|
<a&b></li>
|
99
95
|
<li>["c",'d']
|
100
|
-
["c"
|
96
|
+
["c",'d']</li>
|
101
97
|
</ul>
|
102
98
|
END
|
103
99
|
OUTPUT2.gsub!(/\n/, "\r\n")
|
@@ -125,7 +121,8 @@ CONTEXT2 = <<'END'
|
|
125
121
|
END
|
126
122
|
|
127
123
|
|
128
|
-
class TenjinMainTest
|
124
|
+
class TenjinMainTest
|
125
|
+
include Oktest::TestCase
|
129
126
|
|
130
127
|
filename = __FILE__.sub(/\.\w+$/, '.yaml')
|
131
128
|
#load_yaml_testdata(filename)
|
@@ -165,15 +162,19 @@ class TenjinMainTest < Test::Unit::TestCase
|
|
165
162
|
if @exception.is_a?(@exception)
|
166
163
|
@exception = Kernel.const_get(@exception)
|
167
164
|
end
|
168
|
-
ex =
|
169
|
-
output = main.execute()
|
170
|
-
end
|
165
|
+
ex = ok_(proc { output = main.execute() }).raise?(@exception)
|
171
166
|
if @errormsg
|
172
|
-
|
167
|
+
ok_(ex.to_s) == @errormsg
|
173
168
|
end
|
174
169
|
else
|
170
|
+
if RUBY_VERSION >= '1.9'
|
171
|
+
if @name =~ /lint/
|
172
|
+
@expected.gsub!(/kIN/, 'keyword_in')
|
173
|
+
@expected.gsub!(/kEND/, 'keyword_end')
|
174
|
+
end
|
175
|
+
end
|
175
176
|
output = main.execute()
|
176
|
-
|
177
|
+
ok_(output) == @expected
|
177
178
|
end
|
178
179
|
ensure
|
179
180
|
to_list(@filename).each { |fname| File.unlink(fname) } if @filename
|
@@ -570,7 +571,11 @@ END
|
|
570
571
|
if defined?(RBX_VERSION)
|
571
572
|
@exception = RbYAML::ScannerError
|
572
573
|
else
|
573
|
-
|
574
|
+
if defined?(Psych::SyntaxError)
|
575
|
+
@exception = Psych::SyntaxError
|
576
|
+
else
|
577
|
+
@exception = ArgumentError
|
578
|
+
end
|
574
579
|
end
|
575
580
|
_test()
|
576
581
|
end
|
@@ -580,7 +585,7 @@ END
|
|
580
585
|
#@options = "--escapefunc=CGI.escapeHTML"
|
581
586
|
@options = "--escapefunc=ERB::Util.html_escape"
|
582
587
|
@input = INPUT
|
583
|
-
@expected = OUTPUT
|
588
|
+
@expected = OUTPUT.gsub(/'/, "'")
|
584
589
|
@exception = NameError
|
585
590
|
if defined?(RBX_VERSION)
|
586
591
|
#@errormsg = "Missing or uninitialized constant: CGI"
|
@@ -592,12 +597,16 @@ END
|
|
592
597
|
#@errormsg = "uninitialized constant Tenjin::Template::CGI"
|
593
598
|
@errormsg = "uninitialized constant Tenjin::Template::ERB"
|
594
599
|
end
|
600
|
+
if RUBY_VERSION >= "1.9.0"
|
601
|
+
@errormsg = @errormsg.gsub(/Missing uninitialized constant/, "uninitialized constant")
|
602
|
+
@expected = @expected.gsub(/expecting kEND/, "expecting keyword_end")
|
603
|
+
end
|
595
604
|
_test()
|
596
605
|
#
|
597
606
|
#@options = "-r cgi --escapefunc=CGI.escapeHTML"
|
598
607
|
@options = "-r erb --escapefunc=ERB::Util.html_escape"
|
599
608
|
@input = INPUT
|
600
|
-
@expected = OUTPUT
|
609
|
+
@expected = OUTPUT.gsub(/'/, "'")
|
601
610
|
@exception = nil
|
602
611
|
@errormsg = nil
|
603
612
|
_test()
|
@@ -639,7 +648,7 @@ END
|
|
639
648
|
def test_templateclass() # --templateclass
|
640
649
|
@options = "--templateclass=Tenjin::ArrayBufferTemplate -s"
|
641
650
|
@input = INPUT
|
642
|
-
@expected = SOURCE4
|
651
|
+
@expected = SOURCE4.sub(/_buf\.to_s/, '_buf.join')
|
643
652
|
_test()
|
644
653
|
@options = "--templateclass=Tenjin::ArrayBufferTemplate"
|
645
654
|
@expected = OUTPUT
|
@@ -742,7 +751,9 @@ END
|
|
742
751
|
end
|
743
752
|
|
744
753
|
|
745
|
-
|
754
|
+
end
|
746
755
|
|
747
756
|
|
757
|
+
if __FILE__ == $0
|
758
|
+
Oktest.run_all()
|
748
759
|
end
|