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
@@ -1,242 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
-
<!DOCTYPE html
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
-
|
6
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
-
<head>
|
8
|
-
<title>Class: Tenjin::Preprocessor</title>
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
-
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
-
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
12
|
-
<script type="text/javascript">
|
13
|
-
// <![CDATA[
|
14
|
-
|
15
|
-
function popupCode( url ) {
|
16
|
-
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
-
}
|
18
|
-
|
19
|
-
function toggleCode( id ) {
|
20
|
-
if ( document.getElementById )
|
21
|
-
elem = document.getElementById( id );
|
22
|
-
else if ( document.all )
|
23
|
-
elem = eval( "document.all." + id );
|
24
|
-
else
|
25
|
-
return false;
|
26
|
-
|
27
|
-
elemStyle = elem.style;
|
28
|
-
|
29
|
-
if ( elemStyle.display != "block" ) {
|
30
|
-
elemStyle.display = "block"
|
31
|
-
} else {
|
32
|
-
elemStyle.display = "none"
|
33
|
-
}
|
34
|
-
|
35
|
-
return true;
|
36
|
-
}
|
37
|
-
|
38
|
-
// Make codeblocks hidden by default
|
39
|
-
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
-
|
41
|
-
// ]]>
|
42
|
-
</script>
|
43
|
-
|
44
|
-
</head>
|
45
|
-
<body>
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
<div id="classHeader">
|
50
|
-
<table class="header-table">
|
51
|
-
<tr class="top-aligned-row">
|
52
|
-
<td><strong>Class</strong></td>
|
53
|
-
<td class="class-name-in-header">Tenjin::Preprocessor</td>
|
54
|
-
</tr>
|
55
|
-
<tr class="top-aligned-row">
|
56
|
-
<td><strong>In:</strong></td>
|
57
|
-
<td>
|
58
|
-
<a href="../../files/lib/tenjin_rb.html">
|
59
|
-
lib/tenjin.rb
|
60
|
-
</a>
|
61
|
-
<br />
|
62
|
-
</td>
|
63
|
-
</tr>
|
64
|
-
|
65
|
-
<tr class="top-aligned-row">
|
66
|
-
<td><strong>Parent:</strong></td>
|
67
|
-
<td>
|
68
|
-
<a href="Template.html">
|
69
|
-
Template
|
70
|
-
</a>
|
71
|
-
</td>
|
72
|
-
</tr>
|
73
|
-
</table>
|
74
|
-
</div>
|
75
|
-
<!-- banner header -->
|
76
|
-
|
77
|
-
<div id="bodyContent">
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
<div id="contextContent">
|
82
|
-
|
83
|
-
<div id="description">
|
84
|
-
<p>
|
85
|
-
preprocessor class
|
86
|
-
</p>
|
87
|
-
|
88
|
-
</div>
|
89
|
-
|
90
|
-
|
91
|
-
</div>
|
92
|
-
|
93
|
-
<div id="method-list">
|
94
|
-
<h3 class="section-bar">Methods</h3>
|
95
|
-
|
96
|
-
<div class="name-list">
|
97
|
-
<a href="#M000046">add_expr</a>
|
98
|
-
<a href="#M000045">escape_str</a>
|
99
|
-
<a href="#M000044">expr_pattern</a>
|
100
|
-
<a href="#M000043">stmt_pattern</a>
|
101
|
-
</div>
|
102
|
-
</div>
|
103
|
-
|
104
|
-
</div>
|
105
|
-
|
106
|
-
|
107
|
-
<!-- if includes -->
|
108
|
-
|
109
|
-
<div id="section">
|
110
|
-
|
111
|
-
|
112
|
-
<div id="constants-list">
|
113
|
-
<h3 class="section-bar">Constants</h3>
|
114
|
-
|
115
|
-
<div class="name-list">
|
116
|
-
<table summary="Constants">
|
117
|
-
<tr class="top-aligned-row context-row">
|
118
|
-
<td class="context-item-name">STMT_PATTERN</td>
|
119
|
-
<td>=</td>
|
120
|
-
<td class="context-item-value">compile_stmt_pattern('RB')</td>
|
121
|
-
</tr>
|
122
|
-
</table>
|
123
|
-
</div>
|
124
|
-
</div>
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
<!-- if method_list -->
|
132
|
-
<div id="methods">
|
133
|
-
<h3 class="section-bar">Protected Instance methods</h3>
|
134
|
-
|
135
|
-
<div id="method-M000046" class="method-detail">
|
136
|
-
<a name="M000046"></a>
|
137
|
-
|
138
|
-
<div class="method-heading">
|
139
|
-
<a href="#M000046" class="method-signature">
|
140
|
-
<span class="method-name">add_expr</span><span class="method-args">(code, flag_escape=nil)</span>
|
141
|
-
</a>
|
142
|
-
</div>
|
143
|
-
|
144
|
-
<div class="method-description">
|
145
|
-
<p><a class="source-toggle" href="#"
|
146
|
-
onclick="toggleCode('M000046-source');return false;">[Source]</a></p>
|
147
|
-
<div class="method-source-code" id="M000046-source">
|
148
|
-
<pre>
|
149
|
-
<span class="ruby-comment cmt"># File lib/tenjin.rb, line 660</span>
|
150
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_expr</span>(<span class="ruby-identifier">code</span>, <span class="ruby-identifier">flag_escape</span>=<span class="ruby-keyword kw">nil</span>)
|
151
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">code</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">code</span>.<span class="ruby-identifier">empty?</span>
|
152
|
-
<span class="ruby-keyword kw">super</span>(<span class="ruby-node">"_decode_params((#{code}))"</span>, <span class="ruby-identifier">flag_escape</span>)
|
153
|
-
<span class="ruby-keyword kw">end</span>
|
154
|
-
</pre>
|
155
|
-
</div>
|
156
|
-
</div>
|
157
|
-
</div>
|
158
|
-
|
159
|
-
<div id="method-M000045" class="method-detail">
|
160
|
-
<a name="M000045"></a>
|
161
|
-
|
162
|
-
<div class="method-heading">
|
163
|
-
<a href="#M000045" class="method-signature">
|
164
|
-
<span class="method-name">escape_str</span><span class="method-args">(str)</span>
|
165
|
-
</a>
|
166
|
-
</div>
|
167
|
-
|
168
|
-
<div class="method-description">
|
169
|
-
<p><a class="source-toggle" href="#"
|
170
|
-
onclick="toggleCode('M000045-source');return false;">[Source]</a></p>
|
171
|
-
<div class="method-source-code" id="M000045-source">
|
172
|
-
<pre>
|
173
|
-
<span class="ruby-comment cmt"># File lib/tenjin.rb, line 654</span>
|
174
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">escape_str</span>(<span class="ruby-identifier">str</span>)
|
175
|
-
<span class="ruby-identifier">str</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp re">/[\\`\#]/</span>, <span class="ruby-value str">'\\\\\&'</span>)
|
176
|
-
<span class="ruby-identifier">str</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp re">/\r\n/</span>, <span class="ruby-value str">"\\r\r\n"</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@newline</span> <span class="ruby-operator">==</span> <span class="ruby-value str">"\r\n"</span>
|
177
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">str</span>
|
178
|
-
<span class="ruby-keyword kw">end</span>
|
179
|
-
</pre>
|
180
|
-
</div>
|
181
|
-
</div>
|
182
|
-
</div>
|
183
|
-
|
184
|
-
<div id="method-M000044" class="method-detail">
|
185
|
-
<a name="M000044"></a>
|
186
|
-
|
187
|
-
<div class="method-heading">
|
188
|
-
<a href="#M000044" class="method-signature">
|
189
|
-
<span class="method-name">expr_pattern</span><span class="method-args">()</span>
|
190
|
-
</a>
|
191
|
-
</div>
|
192
|
-
|
193
|
-
<div class="method-description">
|
194
|
-
<p><a class="source-toggle" href="#"
|
195
|
-
onclick="toggleCode('M000044-source');return false;">[Source]</a></p>
|
196
|
-
<div class="method-source-code" id="M000044-source">
|
197
|
-
<pre>
|
198
|
-
<span class="ruby-comment cmt"># File lib/tenjin.rb, line 644</span>
|
199
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">expr_pattern</span>
|
200
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-regexp re">/([\#$])\{\{(.*?)\}\}/</span><span class="ruby-identifier">m</span>
|
201
|
-
<span class="ruby-keyword kw">end</span>
|
202
|
-
</pre>
|
203
|
-
</div>
|
204
|
-
</div>
|
205
|
-
</div>
|
206
|
-
|
207
|
-
<div id="method-M000043" class="method-detail">
|
208
|
-
<a name="M000043"></a>
|
209
|
-
|
210
|
-
<div class="method-heading">
|
211
|
-
<a href="#M000043" class="method-signature">
|
212
|
-
<span class="method-name">stmt_pattern</span><span class="method-args">()</span>
|
213
|
-
</a>
|
214
|
-
</div>
|
215
|
-
|
216
|
-
<div class="method-description">
|
217
|
-
<p><a class="source-toggle" href="#"
|
218
|
-
onclick="toggleCode('M000043-source');return false;">[Source]</a></p>
|
219
|
-
<div class="method-source-code" id="M000043-source">
|
220
|
-
<pre>
|
221
|
-
<span class="ruby-comment cmt"># File lib/tenjin.rb, line 640</span>
|
222
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">stmt_pattern</span>
|
223
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-constant">STMT_PATTERN</span>
|
224
|
-
<span class="ruby-keyword kw">end</span>
|
225
|
-
</pre>
|
226
|
-
</div>
|
227
|
-
</div>
|
228
|
-
</div>
|
229
|
-
|
230
|
-
|
231
|
-
</div>
|
232
|
-
|
233
|
-
|
234
|
-
</div>
|
235
|
-
|
236
|
-
|
237
|
-
<div id="validator-badges">
|
238
|
-
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
239
|
-
</div>
|
240
|
-
|
241
|
-
</body>
|
242
|
-
</html>
|
@@ -1,916 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
-
<!DOCTYPE html
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
-
|
6
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
-
<head>
|
8
|
-
<title>Class: Tenjin::Template</title>
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
-
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
-
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
12
|
-
<script type="text/javascript">
|
13
|
-
// <![CDATA[
|
14
|
-
|
15
|
-
function popupCode( url ) {
|
16
|
-
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
-
}
|
18
|
-
|
19
|
-
function toggleCode( id ) {
|
20
|
-
if ( document.getElementById )
|
21
|
-
elem = document.getElementById( id );
|
22
|
-
else if ( document.all )
|
23
|
-
elem = eval( "document.all." + id );
|
24
|
-
else
|
25
|
-
return false;
|
26
|
-
|
27
|
-
elemStyle = elem.style;
|
28
|
-
|
29
|
-
if ( elemStyle.display != "block" ) {
|
30
|
-
elemStyle.display = "block"
|
31
|
-
} else {
|
32
|
-
elemStyle.display = "none"
|
33
|
-
}
|
34
|
-
|
35
|
-
return true;
|
36
|
-
}
|
37
|
-
|
38
|
-
// Make codeblocks hidden by default
|
39
|
-
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
-
|
41
|
-
// ]]>
|
42
|
-
</script>
|
43
|
-
|
44
|
-
</head>
|
45
|
-
<body>
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
<div id="classHeader">
|
50
|
-
<table class="header-table">
|
51
|
-
<tr class="top-aligned-row">
|
52
|
-
<td><strong>Class</strong></td>
|
53
|
-
<td class="class-name-in-header">Tenjin::Template</td>
|
54
|
-
</tr>
|
55
|
-
<tr class="top-aligned-row">
|
56
|
-
<td><strong>In:</strong></td>
|
57
|
-
<td>
|
58
|
-
<a href="../../files/lib/tenjin_rb.html">
|
59
|
-
lib/tenjin.rb
|
60
|
-
</a>
|
61
|
-
<br />
|
62
|
-
</td>
|
63
|
-
</tr>
|
64
|
-
|
65
|
-
<tr class="top-aligned-row">
|
66
|
-
<td><strong>Parent:</strong></td>
|
67
|
-
<td>
|
68
|
-
Object
|
69
|
-
</td>
|
70
|
-
</tr>
|
71
|
-
</table>
|
72
|
-
</div>
|
73
|
-
<!-- banner header -->
|
74
|
-
|
75
|
-
<div id="bodyContent">
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
<div id="contextContent">
|
80
|
-
|
81
|
-
<div id="description">
|
82
|
-
<p>
|
83
|
-
template class
|
84
|
-
</p>
|
85
|
-
<p>
|
86
|
-
ex. file ‘example.rbhtml‘
|
87
|
-
</p>
|
88
|
-
<pre>
|
89
|
-
<html>
|
90
|
-
<body>
|
91
|
-
<h1>${@title}</h1>
|
92
|
-
<ul>
|
93
|
-
<?rb i = 0 ?>
|
94
|
-
<?rb for item in @items ?>
|
95
|
-
<?rb i += 1 ?>
|
96
|
-
<li>#{i} : ${item}</li>
|
97
|
-
<?rb end ?>
|
98
|
-
</ul>
|
99
|
-
</body>
|
100
|
-
</html>
|
101
|
-
</pre>
|
102
|
-
<p>
|
103
|
-
ex. convertion
|
104
|
-
</p>
|
105
|
-
<pre>
|
106
|
-
require 'tenjin'
|
107
|
-
template = Tenjin::Template.new('example.rbhtml')
|
108
|
-
print template.script
|
109
|
-
## or
|
110
|
-
# template = Tenjin::Template.new()
|
111
|
-
# print template.convert_file('example.rbhtml')
|
112
|
-
## or
|
113
|
-
# template = Tenjin::Template.new()
|
114
|
-
# fname = 'example.rbhtml'
|
115
|
-
# print template.convert(File.read(fname), fname) # filename is optional
|
116
|
-
</pre>
|
117
|
-
<p>
|
118
|
-
ex. evaluation
|
119
|
-
</p>
|
120
|
-
<pre>
|
121
|
-
context = {:title=>'Tenjin Example', :items=>['foo', 'bar', 'baz'] }
|
122
|
-
output = template.render(context)
|
123
|
-
## or
|
124
|
-
# context = Tenjin::Context(:title=>'Tenjin Example', :items=>['foo','bar','baz'])
|
125
|
-
# output = template.render(context)
|
126
|
-
## or
|
127
|
-
# output = template.render(:title=>'Tenjin Example', :items=>['foo','bar','baz'])
|
128
|
-
print output
|
129
|
-
</pre>
|
130
|
-
|
131
|
-
</div>
|
132
|
-
|
133
|
-
|
134
|
-
</div>
|
135
|
-
|
136
|
-
<div id="method-list">
|
137
|
-
<h3 class="section-bar">Methods</h3>
|
138
|
-
|
139
|
-
<div class="name-list">
|
140
|
-
<a href="#M000063">add_expr</a>
|
141
|
-
<a href="#M000064">add_stmt</a>
|
142
|
-
<a href="#M000061">add_text</a>
|
143
|
-
<a href="#M000051">after_convert</a>
|
144
|
-
<a href="#M000050">before_convert</a>
|
145
|
-
<a href="#M000052">compile_stmt_pattern</a>
|
146
|
-
<a href="#M000049">convert</a>
|
147
|
-
<a href="#M000048">convert_file</a>
|
148
|
-
<a href="#M000062">escape_str</a>
|
149
|
-
<a href="#M000055">expr_pattern</a>
|
150
|
-
<a href="#M000056">get_expr_and_escapeflag</a>
|
151
|
-
<a href="#M000047">new</a>
|
152
|
-
<a href="#M000057">parse_exprs</a>
|
153
|
-
<a href="#M000054">parse_stmts</a>
|
154
|
-
<a href="#M000065">render</a>
|
155
|
-
<a href="#M000059">start_text_part</a>
|
156
|
-
<a href="#M000058">statement_hook</a>
|
157
|
-
<a href="#M000053">stmt_pattern</a>
|
158
|
-
<a href="#M000060">stop_text_part</a>
|
159
|
-
</div>
|
160
|
-
</div>
|
161
|
-
|
162
|
-
</div>
|
163
|
-
|
164
|
-
|
165
|
-
<!-- if includes -->
|
166
|
-
|
167
|
-
<div id="section">
|
168
|
-
|
169
|
-
|
170
|
-
<div id="constants-list">
|
171
|
-
<h3 class="section-bar">Constants</h3>
|
172
|
-
|
173
|
-
<div class="name-list">
|
174
|
-
<table summary="Constants">
|
175
|
-
<tr class="top-aligned-row context-row">
|
176
|
-
<td class="context-item-name">ESCAPE_FUNCTION</td>
|
177
|
-
<td>=</td>
|
178
|
-
<td class="context-item-value">'escape'</td>
|
179
|
-
</tr>
|
180
|
-
<tr class="top-aligned-row context-row">
|
181
|
-
<td class="context-item-name">STMT_PATTERN</td>
|
182
|
-
<td>=</td>
|
183
|
-
<td class="context-item-value">self.compile_stmt_pattern('rb')</td>
|
184
|
-
</tr>
|
185
|
-
</table>
|
186
|
-
</div>
|
187
|
-
</div>
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
<div id="attribute-list">
|
192
|
-
<h3 class="section-bar">Attributes</h3>
|
193
|
-
|
194
|
-
<div class="name-list">
|
195
|
-
<table>
|
196
|
-
<tr class="top-aligned-row context-row">
|
197
|
-
<td class="context-item-name">args</td>
|
198
|
-
<td class="context-item-value"> [RW] </td>
|
199
|
-
<td class="context-item-desc"></td>
|
200
|
-
</tr>
|
201
|
-
<tr class="top-aligned-row context-row">
|
202
|
-
<td class="context-item-name">escapefunc</td>
|
203
|
-
<td class="context-item-value"> [RW] </td>
|
204
|
-
<td class="context-item-desc"></td>
|
205
|
-
</tr>
|
206
|
-
<tr class="top-aligned-row context-row">
|
207
|
-
<td class="context-item-name">filename</td>
|
208
|
-
<td class="context-item-value"> [RW] </td>
|
209
|
-
<td class="context-item-desc"></td>
|
210
|
-
</tr>
|
211
|
-
<tr class="top-aligned-row context-row">
|
212
|
-
<td class="context-item-name">initbuf</td>
|
213
|
-
<td class="context-item-value"> [RW] </td>
|
214
|
-
<td class="context-item-desc"></td>
|
215
|
-
</tr>
|
216
|
-
<tr class="top-aligned-row context-row">
|
217
|
-
<td class="context-item-name">newline</td>
|
218
|
-
<td class="context-item-value"> [RW] </td>
|
219
|
-
<td class="context-item-desc"></td>
|
220
|
-
</tr>
|
221
|
-
<tr class="top-aligned-row context-row">
|
222
|
-
<td class="context-item-name">script</td>
|
223
|
-
<td class="context-item-value"> [RW] </td>
|
224
|
-
<td class="context-item-desc"></td>
|
225
|
-
</tr>
|
226
|
-
<tr class="top-aligned-row context-row">
|
227
|
-
<td class="context-item-name">timestamp</td>
|
228
|
-
<td class="context-item-value"> [RW] </td>
|
229
|
-
<td class="context-item-desc"></td>
|
230
|
-
</tr>
|
231
|
-
</table>
|
232
|
-
</div>
|
233
|
-
</div>
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
<!-- if method_list -->
|
238
|
-
<div id="methods">
|
239
|
-
<h3 class="section-bar">Public Class methods</h3>
|
240
|
-
|
241
|
-
<div id="method-M000047" class="method-detail">
|
242
|
-
<a name="M000047"></a>
|
243
|
-
|
244
|
-
<div class="method-heading">
|
245
|
-
<a href="#M000047" class="method-signature">
|
246
|
-
<span class="method-name">new</span><span class="method-args">(filename=nil, options={})</span>
|
247
|
-
</a>
|
248
|
-
</div>
|
249
|
-
|
250
|
-
<div class="method-description">
|
251
|
-
<p>
|
252
|
-
initializer of <a href="Template.html">Template</a> class.
|
253
|
-
</p>
|
254
|
-
<p>
|
255
|
-
options:
|
256
|
-
</p>
|
257
|
-
<table>
|
258
|
-
<tr><td valign="top">:escapefunc :</td><td>function name to escape value (default ‘escape’)
|
259
|
-
|
260
|
-
</td></tr>
|
261
|
-
<tr><td valign="top">:preamble :</td><td>preamble such as "_buf = ’’" (default nil)
|
262
|
-
|
263
|
-
</td></tr>
|
264
|
-
<tr><td valign="top">:postamble :</td><td>postamble such as "_buf.to_s" (default nil)
|
265
|
-
|
266
|
-
</td></tr>
|
267
|
-
</table>
|
268
|
-
<p><a class="source-toggle" href="#"
|
269
|
-
onclick="toggleCode('M000047-source');return false;">[Source]</a></p>
|
270
|
-
<div class="method-source-code" id="M000047-source">
|
271
|
-
<pre>
|
272
|
-
<span class="ruby-comment cmt"># File lib/tenjin.rb, line 337</span>
|
273
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">filename</span>=<span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">options</span>={})
|
274
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">filename</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>)
|
275
|
-
<span class="ruby-identifier">options</span> = <span class="ruby-identifier">filename</span>
|
276
|
-
<span class="ruby-identifier">filename</span> = <span class="ruby-keyword kw">nil</span>
|
277
|
-
<span class="ruby-keyword kw">end</span>
|
278
|
-
<span class="ruby-ivar">@filename</span> = <span class="ruby-identifier">filename</span>
|
279
|
-
<span class="ruby-ivar">@escapefunc</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:escapefunc</span>] <span class="ruby-operator">||</span> <span class="ruby-constant">ESCAPE_FUNCTION</span>
|
280
|
-
<span class="ruby-ivar">@preamble</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:preamble</span>] <span class="ruby-operator">==</span> <span class="ruby-keyword kw">true</span> <span class="ruby-operator">?</span> <span class="ruby-node">"_buf = #{init_buf_expr()}; "</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:preamble</span>]
|
281
|
-
<span class="ruby-ivar">@postamble</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:postamble</span>] <span class="ruby-operator">==</span> <span class="ruby-keyword kw">true</span> <span class="ruby-operator">?</span> <span class="ruby-value str">"_buf.to_s"</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:postamble</span>]
|
282
|
-
<span class="ruby-ivar">@args</span> = <span class="ruby-keyword kw">nil</span> <span class="ruby-comment cmt"># or array of argument names</span>
|
283
|
-
<span class="ruby-identifier">convert_file</span>(<span class="ruby-identifier">filename</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">filename</span>
|
284
|
-
<span class="ruby-keyword kw">end</span>
|
285
|
-
</pre>
|
286
|
-
</div>
|
287
|
-
</div>
|
288
|
-
</div>
|
289
|
-
|
290
|
-
<h3 class="section-bar">Protected Class methods</h3>
|
291
|
-
|
292
|
-
<div id="method-M000052" class="method-detail">
|
293
|
-
<a name="M000052"></a>
|
294
|
-
|
295
|
-
<div class="method-heading">
|
296
|
-
<a href="#M000052" class="method-signature">
|
297
|
-
<span class="method-name">compile_stmt_pattern</span><span class="method-args">(pi)</span>
|
298
|
-
</a>
|
299
|
-
</div>
|
300
|
-
|
301
|
-
<div class="method-description">
|
302
|
-
<p><a class="source-toggle" href="#"
|
303
|
-
onclick="toggleCode('M000052-source');return false;">[Source]</a></p>
|
304
|
-
<div class="method-source-code" id="M000052-source">
|
305
|
-
<pre>
|
306
|
-
<span class="ruby-comment cmt"># File lib/tenjin.rb, line 391</span>
|
307
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">compile_stmt_pattern</span>(<span class="ruby-identifier">pi</span>)
|
308
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-node">/<\?#{pi}( |\t|\r?\n)(.*?) ?\?>([ \t]*\r?\n)?/</span><span class="ruby-identifier">m</span>
|
309
|
-
<span class="ruby-keyword kw">end</span>
|
310
|
-
</pre>
|
311
|
-
</div>
|
312
|
-
</div>
|
313
|
-
</div>
|
314
|
-
|
315
|
-
<h3 class="section-bar">Public Instance methods</h3>
|
316
|
-
|
317
|
-
<div id="method-M000049" class="method-detail">
|
318
|
-
<a name="M000049"></a>
|
319
|
-
|
320
|
-
<div class="method-heading">
|
321
|
-
<a href="#M000049" class="method-signature">
|
322
|
-
<span class="method-name">convert</span><span class="method-args">(input, filename=nil)</span>
|
323
|
-
</a>
|
324
|
-
</div>
|
325
|
-
|
326
|
-
<div class="method-description">
|
327
|
-
<p>
|
328
|
-
<a href="Template.html#M000049">convert</a> string into ruby code
|
329
|
-
</p>
|
330
|
-
<p><a class="source-toggle" href="#"
|
331
|
-
onclick="toggleCode('M000049-source');return false;">[Source]</a></p>
|
332
|
-
<div class="method-source-code" id="M000049-source">
|
333
|
-
<pre>
|
334
|
-
<span class="ruby-comment cmt"># File lib/tenjin.rb, line 359</span>
|
335
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">convert</span>(<span class="ruby-identifier">input</span>, <span class="ruby-identifier">filename</span>=<span class="ruby-keyword kw">nil</span>)
|
336
|
-
<span class="ruby-ivar">@input</span> = <span class="ruby-identifier">input</span>
|
337
|
-
<span class="ruby-ivar">@filename</span> = <span class="ruby-identifier">filename</span>
|
338
|
-
<span class="ruby-ivar">@proc</span> = <span class="ruby-keyword kw">nil</span>
|
339
|
-
<span class="ruby-identifier">pos</span> = <span class="ruby-identifier">input</span>.<span class="ruby-identifier">index</span>(<span class="ruby-value">?\n</span>)
|
340
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">pos</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">input</span>[<span class="ruby-identifier">pos</span><span class="ruby-operator">-</span><span class="ruby-value">1</span>] <span class="ruby-operator">==</span> <span class="ruby-value">?\r</span>
|
341
|
-
<span class="ruby-ivar">@newline</span> = <span class="ruby-value str">"\r\n"</span>
|
342
|
-
<span class="ruby-ivar">@newlinestr</span> = <span class="ruby-value str">'\\r\\n'</span>
|
343
|
-
<span class="ruby-keyword kw">else</span>
|
344
|
-
<span class="ruby-ivar">@newline</span> = <span class="ruby-value str">"\n"</span>
|
345
|
-
<span class="ruby-ivar">@newlinestr</span> = <span class="ruby-value str">'\\n'</span>
|
346
|
-
<span class="ruby-keyword kw">end</span>
|
347
|
-
<span class="ruby-identifier">before_convert</span>()
|
348
|
-
<span class="ruby-identifier">parse_stmts</span>(<span class="ruby-identifier">input</span>)
|
349
|
-
<span class="ruby-identifier">after_convert</span>()
|
350
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@script</span>
|
351
|
-
<span class="ruby-keyword kw">end</span>
|
352
|
-
</pre>
|
353
|
-
</div>
|
354
|
-
</div>
|
355
|
-
</div>
|
356
|
-
|
357
|
-
<div id="method-M000048" class="method-detail">
|
358
|
-
<a name="M000048"></a>
|
359
|
-
|
360
|
-
<div class="method-heading">
|
361
|
-
<a href="#M000048" class="method-signature">
|
362
|
-
<span class="method-name">convert_file</span><span class="method-args">(filename)</span>
|
363
|
-
</a>
|
364
|
-
</div>
|
365
|
-
|
366
|
-
<div class="method-description">
|
367
|
-
<p>
|
368
|
-
<a href="Template.html#M000049">convert</a> file into ruby code
|
369
|
-
</p>
|
370
|
-
<p><a class="source-toggle" href="#"
|
371
|
-
onclick="toggleCode('M000048-source');return false;">[Source]</a></p>
|
372
|
-
<div class="method-source-code" id="M000048-source">
|
373
|
-
<pre>
|
374
|
-
<span class="ruby-comment cmt"># File lib/tenjin.rb, line 354</span>
|
375
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">convert_file</span>(<span class="ruby-identifier">filename</span>)
|
376
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">convert</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span>(<span class="ruby-identifier">filename</span>), <span class="ruby-identifier">filename</span>)
|
377
|
-
<span class="ruby-keyword kw">end</span>
|
378
|
-
</pre>
|
379
|
-
</div>
|
380
|
-
</div>
|
381
|
-
</div>
|
382
|
-
|
383
|
-
<div id="method-M000065" class="method-detail">
|
384
|
-
<a name="M000065"></a>
|
385
|
-
|
386
|
-
<div class="method-heading">
|
387
|
-
<a href="#M000065" class="method-signature">
|
388
|
-
<span class="method-name">render</span><span class="method-args">(_context=Context.new)</span>
|
389
|
-
</a>
|
390
|
-
</div>
|
391
|
-
|
392
|
-
<div class="method-description">
|
393
|
-
<p>
|
394
|
-
evaluate converted ruby code and return it. argument ‘_context’
|
395
|
-
should be a Hash object or <a href="Context.html">Context</a> object.
|
396
|
-
</p>
|
397
|
-
<p><a class="source-toggle" href="#"
|
398
|
-
onclick="toggleCode('M000065-source');return false;">[Source]</a></p>
|
399
|
-
<div class="method-source-code" id="M000065-source">
|
400
|
-
<pre>
|
401
|
-
<span class="ruby-comment cmt"># File lib/tenjin.rb, line 622</span>
|
402
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">render</span>(<span class="ruby-identifier">_context</span>=<span class="ruby-constant">Context</span>.<span class="ruby-identifier">new</span>)
|
403
|
-
<span class="ruby-identifier">_context</span> = <span class="ruby-constant">Context</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">_context</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">_context</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>)
|
404
|
-
<span class="ruby-ivar">@proc</span> <span class="ruby-operator">||=</span> <span class="ruby-identifier">_render</span>()
|
405
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">_context</span>.<span class="ruby-identifier">instance_eval</span>(<span class="ruby-operator">&</span><span class="ruby-ivar">@proc</span>)
|
406
|
-
<span class="ruby-keyword kw">end</span>
|
407
|
-
</pre>
|
408
|
-
</div>
|
409
|
-
</div>
|
410
|
-
</div>
|
411
|
-
|
412
|
-
<h3 class="section-bar">Protected Instance methods</h3>
|
413
|
-
|
414
|
-
<div id="method-M000063" class="method-detail">
|
415
|
-
<a name="M000063"></a>
|
416
|
-
|
417
|
-
<div class="method-heading">
|
418
|
-
<a href="#M000063" class="method-signature">
|
419
|
-
<span class="method-name">add_expr</span><span class="method-args">(code, flag_escape=nil)</span>
|
420
|
-
</a>
|
421
|
-
</div>
|
422
|
-
|
423
|
-
<div class="method-description">
|
424
|
-
<p>
|
425
|
-
add expression code
|
426
|
-
</p>
|
427
|
-
<p><a class="source-toggle" href="#"
|
428
|
-
onclick="toggleCode('M000063-source');return false;">[Source]</a></p>
|
429
|
-
<div class="method-source-code" id="M000063-source">
|
430
|
-
<pre>
|
431
|
-
<span class="ruby-comment cmt"># File lib/tenjin.rb, line 597</span>
|
432
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_expr</span>(<span class="ruby-identifier">code</span>, <span class="ruby-identifier">flag_escape</span>=<span class="ruby-keyword kw">nil</span>)
|
433
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">code</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">code</span>.<span class="ruby-identifier">empty?</span>
|
434
|
-
<span class="ruby-ivar">@script</span> <span class="ruby-operator"><<</span> (<span class="ruby-identifier">flag_escape</span> <span class="ruby-value">? </span><span class="ruby-node">"\#{#{@escapefunc}((#{code}).to_s)}"</span> <span class="ruby-operator">:</span> <span class="ruby-node">"\#{#{code}}"</span>)
|
435
|
-
<span class="ruby-keyword kw">end</span>
|
436
|
-
</pre>
|
437
|
-
</div>
|
438
|
-
</div>
|
439
|
-
</div>
|
440
|
-
|
441
|
-
<div id="method-M000064" class="method-detail">
|
442
|
-
<a name="M000064"></a>
|
443
|
-
|
444
|
-
<div class="method-heading">
|
445
|
-
<a href="#M000064" class="method-signature">
|
446
|
-
<span class="method-name">add_stmt</span><span class="method-args">(code)</span>
|
447
|
-
</a>
|
448
|
-
</div>
|
449
|
-
|
450
|
-
<div class="method-description">
|
451
|
-
<p>
|
452
|
-
add statement code
|
453
|
-
</p>
|
454
|
-
<p><a class="source-toggle" href="#"
|
455
|
-
onclick="toggleCode('M000064-source');return false;">[Source]</a></p>
|
456
|
-
<div class="method-source-code" id="M000064-source">
|
457
|
-
<pre>
|
458
|
-
<span class="ruby-comment cmt"># File lib/tenjin.rb, line 603</span>
|
459
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_stmt</span>(<span class="ruby-identifier">code</span>)
|
460
|
-
<span class="ruby-ivar">@script</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">code</span>
|
461
|
-
<span class="ruby-keyword kw">end</span>
|
462
|
-
</pre>
|
463
|
-
</div>
|
464
|
-
</div>
|
465
|
-
</div>
|
466
|
-
|
467
|
-
<div id="method-M000061" class="method-detail">
|
468
|
-
<a name="M000061"></a>
|
469
|
-
|
470
|
-
<div class="method-heading">
|
471
|
-
<a href="#M000061" class="method-signature">
|
472
|
-
<span class="method-name">add_text</span><span class="method-args">(text, encode_newline=false)</span>
|
473
|
-
</a>
|
474
|
-
</div>
|
475
|
-
|
476
|
-
<div class="method-description">
|
477
|
-
<p>
|
478
|
-
add text string
|
479
|
-
</p>
|
480
|
-
<p><a class="source-toggle" href="#"
|
481
|
-
onclick="toggleCode('M000061-source');return false;">[Source]</a></p>
|
482
|
-
<div class="method-source-code" id="M000061-source">
|
483
|
-
<pre>
|
484
|
-
<span class="ruby-comment cmt"># File lib/tenjin.rb, line 579</span>
|
485
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_text</span>(<span class="ruby-identifier">text</span>, <span class="ruby-identifier">encode_newline</span>=<span class="ruby-keyword kw">false</span>)
|
486
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">text</span> <span class="ruby-operator">&&</span> <span class="ruby-operator">!</span><span class="ruby-identifier">text</span>.<span class="ruby-identifier">empty?</span>
|
487
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">encode_newline</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">text</span>[<span class="ruby-value">-1</span>] <span class="ruby-operator">==</span> <span class="ruby-value">?\n</span>
|
488
|
-
<span class="ruby-identifier">text</span>.<span class="ruby-identifier">chomp!</span>
|
489
|
-
<span class="ruby-ivar">@script</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">escape_str</span>(<span class="ruby-identifier">text</span>) <span class="ruby-operator"><<</span> <span class="ruby-ivar">@newlinestr</span>
|
490
|
-
<span class="ruby-keyword kw">else</span>
|
491
|
-
<span class="ruby-ivar">@script</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">escape_str</span>(<span class="ruby-identifier">text</span>)
|
492
|
-
<span class="ruby-keyword kw">end</span>
|
493
|
-
<span class="ruby-keyword kw">end</span>
|
494
|
-
</pre>
|
495
|
-
</div>
|
496
|
-
</div>
|
497
|
-
</div>
|
498
|
-
|
499
|
-
<div id="method-M000051" class="method-detail">
|
500
|
-
<a name="M000051"></a>
|
501
|
-
|
502
|
-
<div class="method-heading">
|
503
|
-
<a href="#M000051" class="method-signature">
|
504
|
-
<span class="method-name">after_convert</span><span class="method-args">()</span>
|
505
|
-
</a>
|
506
|
-
</div>
|
507
|
-
|
508
|
-
<div class="method-description">
|
509
|
-
<p>
|
510
|
-
hook method called after <a href="Template.html#M000049">convert</a>()
|
511
|
-
</p>
|
512
|
-
<p><a class="source-toggle" href="#"
|
513
|
-
onclick="toggleCode('M000051-source');return false;">[Source]</a></p>
|
514
|
-
<div class="method-source-code" id="M000051-source">
|
515
|
-
<pre>
|
516
|
-
<span class="ruby-comment cmt"># File lib/tenjin.rb, line 386</span>
|
517
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">after_convert</span>()
|
518
|
-
<span class="ruby-ivar">@script</span> <span class="ruby-operator"><<</span> <span class="ruby-ivar">@newline</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@script</span>[<span class="ruby-value">-1</span>] <span class="ruby-operator">==</span> <span class="ruby-value">?\n</span>
|
519
|
-
<span class="ruby-ivar">@script</span> <span class="ruby-operator"><<</span> <span class="ruby-ivar">@postamble</span> <span class="ruby-operator"><<</span> <span class="ruby-ivar">@newline</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@postamble</span>
|
520
|
-
<span class="ruby-keyword kw">end</span>
|
521
|
-
</pre>
|
522
|
-
</div>
|
523
|
-
</div>
|
524
|
-
</div>
|
525
|
-
|
526
|
-
<div id="method-M000050" class="method-detail">
|
527
|
-
<a name="M000050"></a>
|
528
|
-
|
529
|
-
<div class="method-heading">
|
530
|
-
<a href="#M000050" class="method-signature">
|
531
|
-
<span class="method-name">before_convert</span><span class="method-args">()</span>
|
532
|
-
</a>
|
533
|
-
</div>
|
534
|
-
|
535
|
-
<div class="method-description">
|
536
|
-
<p>
|
537
|
-
hook method called before <a href="Template.html#M000049">convert</a>()
|
538
|
-
</p>
|
539
|
-
<p><a class="source-toggle" href="#"
|
540
|
-
onclick="toggleCode('M000050-source');return false;">[Source]</a></p>
|
541
|
-
<div class="method-source-code" id="M000050-source">
|
542
|
-
<pre>
|
543
|
-
<span class="ruby-comment cmt"># File lib/tenjin.rb, line 380</span>
|
544
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">before_convert</span>()
|
545
|
-
<span class="ruby-ivar">@script</span> = <span class="ruby-value str">''</span>
|
546
|
-
<span class="ruby-ivar">@script</span> <span class="ruby-operator"><<</span> <span class="ruby-ivar">@preamble</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@preamble</span>
|
547
|
-
<span class="ruby-keyword kw">end</span>
|
548
|
-
</pre>
|
549
|
-
</div>
|
550
|
-
</div>
|
551
|
-
</div>
|
552
|
-
|
553
|
-
<div id="method-M000062" class="method-detail">
|
554
|
-
<a name="M000062"></a>
|
555
|
-
|
556
|
-
<div class="method-heading">
|
557
|
-
<a href="#M000062" class="method-signature">
|
558
|
-
<span class="method-name">escape_str</span><span class="method-args">(str)</span>
|
559
|
-
</a>
|
560
|
-
</div>
|
561
|
-
|
562
|
-
<div class="method-description">
|
563
|
-
<p>
|
564
|
-
escape ’\’ and ’`’ into ’\\’ and
|
565
|
-
’\`’
|
566
|
-
</p>
|
567
|
-
<p><a class="source-toggle" href="#"
|
568
|
-
onclick="toggleCode('M000062-source');return false;">[Source]</a></p>
|
569
|
-
<div class="method-source-code" id="M000062-source">
|
570
|
-
<pre>
|
571
|
-
<span class="ruby-comment cmt"># File lib/tenjin.rb, line 590</span>
|
572
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">escape_str</span>(<span class="ruby-identifier">str</span>)
|
573
|
-
<span class="ruby-identifier">str</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp re">/[`\\]/</span>, <span class="ruby-value str">'\\\\\&'</span>)
|
574
|
-
<span class="ruby-identifier">str</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp re">/\r\n/</span>, <span class="ruby-value str">"\\r\r\n"</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@newline</span> <span class="ruby-operator">==</span> <span class="ruby-value str">"\r\n"</span>
|
575
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">str</span>
|
576
|
-
<span class="ruby-keyword kw">end</span>
|
577
|
-
</pre>
|
578
|
-
</div>
|
579
|
-
</div>
|
580
|
-
</div>
|
581
|
-
|
582
|
-
<div id="method-M000055" class="method-detail">
|
583
|
-
<a name="M000055"></a>
|
584
|
-
|
585
|
-
<div class="method-heading">
|
586
|
-
<a href="#M000055" class="method-signature">
|
587
|
-
<span class="method-name">expr_pattern</span><span class="method-args">()</span>
|
588
|
-
</a>
|
589
|
-
</div>
|
590
|
-
|
591
|
-
<div class="method-description">
|
592
|
-
<p><a class="source-toggle" href="#"
|
593
|
-
onclick="toggleCode('M000055-source');return false;">[Source]</a></p>
|
594
|
-
<div class="method-source-code" id="M000055-source">
|
595
|
-
<pre>
|
596
|
-
<span class="ruby-comment cmt"># File lib/tenjin.rb, line 464</span>
|
597
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">expr_pattern</span>
|
598
|
-
<span class="ruby-comment cmt">#return /([\#$])\{(.*?)\}/</span>
|
599
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-regexp re">/(\$)\{(.*?)\}/</span><span class="ruby-identifier">m</span>
|
600
|
-
<span class="ruby-comment cmt">#return /\$\{.*?\}/</span>
|
601
|
-
<span class="ruby-keyword kw">end</span>
|
602
|
-
</pre>
|
603
|
-
</div>
|
604
|
-
</div>
|
605
|
-
</div>
|
606
|
-
|
607
|
-
<div id="method-M000056" class="method-detail">
|
608
|
-
<a name="M000056"></a>
|
609
|
-
|
610
|
-
<div class="method-heading">
|
611
|
-
<a href="#M000056" class="method-signature">
|
612
|
-
<span class="method-name">get_expr_and_escapeflag</span><span class="method-args">(matched)</span>
|
613
|
-
</a>
|
614
|
-
</div>
|
615
|
-
|
616
|
-
<div class="method-description">
|
617
|
-
<p>
|
618
|
-
ex. <a
|
619
|
-
href="Template.html#M000056">get_expr_and_escapeflag</a>(’$’,
|
620
|
-
‘item[:name]’) => ‘item[:name]’, true
|
621
|
-
</p>
|
622
|
-
<p><a class="source-toggle" href="#"
|
623
|
-
onclick="toggleCode('M000056-source');return false;">[Source]</a></p>
|
624
|
-
<div class="method-source-code" id="M000056-source">
|
625
|
-
<pre>
|
626
|
-
<span class="ruby-comment cmt"># File lib/tenjin.rb, line 471</span>
|
627
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get_expr_and_escapeflag</span>(<span class="ruby-identifier">matched</span>)
|
628
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">matched</span>[<span class="ruby-value">2</span>], <span class="ruby-identifier">matched</span>[<span class="ruby-value">1</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">'$'</span>
|
629
|
-
<span class="ruby-keyword kw">end</span>
|
630
|
-
</pre>
|
631
|
-
</div>
|
632
|
-
</div>
|
633
|
-
</div>
|
634
|
-
|
635
|
-
<div id="method-M000057" class="method-detail">
|
636
|
-
<a name="M000057"></a>
|
637
|
-
|
638
|
-
<div class="method-heading">
|
639
|
-
<a href="#M000057" class="method-signature">
|
640
|
-
<span class="method-name">parse_exprs</span><span class="method-args">(input)</span>
|
641
|
-
</a>
|
642
|
-
</div>
|
643
|
-
|
644
|
-
<div class="method-description">
|
645
|
-
<p>
|
646
|
-
parse expressions (’#{…}’ and ’${…}’)
|
647
|
-
</p>
|
648
|
-
<p><a class="source-toggle" href="#"
|
649
|
-
onclick="toggleCode('M000057-source');return false;">[Source]</a></p>
|
650
|
-
<div class="method-source-code" id="M000057-source">
|
651
|
-
<pre>
|
652
|
-
<span class="ruby-comment cmt"># File lib/tenjin.rb, line 476</span>
|
653
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">parse_exprs</span>(<span class="ruby-identifier">input</span>)
|
654
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">input</span> <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">input</span>.<span class="ruby-identifier">empty?</span>
|
655
|
-
<span class="ruby-identifier">pos</span> = <span class="ruby-value">0</span>
|
656
|
-
<span class="ruby-identifier">start_text_part</span>()
|
657
|
-
<span class="ruby-identifier">input</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-identifier">expr_pattern</span>()) <span class="ruby-keyword kw">do</span>
|
658
|
-
<span class="ruby-identifier">m</span> = <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">last_match</span>
|
659
|
-
<span class="ruby-identifier">text</span> = <span class="ruby-identifier">input</span>[<span class="ruby-identifier">pos</span>, <span class="ruby-identifier">m</span>.<span class="ruby-identifier">begin</span>(<span class="ruby-value">0</span>) <span class="ruby-operator">-</span> <span class="ruby-identifier">pos</span>]
|
660
|
-
<span class="ruby-identifier">pos</span> = <span class="ruby-identifier">m</span>.<span class="ruby-identifier">end</span>(<span class="ruby-value">0</span>)
|
661
|
-
<span class="ruby-identifier">expr</span>, <span class="ruby-identifier">flag_escape</span> = <span class="ruby-identifier">get_expr_and_escapeflag</span>(<span class="ruby-identifier">m</span>)
|
662
|
-
<span class="ruby-comment cmt">#m = Regexp.last_match</span>
|
663
|
-
<span class="ruby-comment cmt">#start = m.begin(0)</span>
|
664
|
-
<span class="ruby-comment cmt">#stop = m.end(0)</span>
|
665
|
-
<span class="ruby-comment cmt">#text = input[pos, start - pos]</span>
|
666
|
-
<span class="ruby-comment cmt">#expr = input[start+2, stop-start-3]</span>
|
667
|
-
<span class="ruby-comment cmt">#pos = stop</span>
|
668
|
-
<span class="ruby-identifier">add_text</span>(<span class="ruby-identifier">text</span>)
|
669
|
-
<span class="ruby-identifier">add_expr</span>(<span class="ruby-identifier">expr</span>, <span class="ruby-identifier">flag_escape</span>)
|
670
|
-
<span class="ruby-keyword kw">end</span>
|
671
|
-
<span class="ruby-identifier">rest</span> = <span class="ruby-identifier">$'</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">input</span>
|
672
|
-
<span class="ruby-comment cmt">#if !rest || rest.empty?</span>
|
673
|
-
<span class="ruby-comment cmt"># @script << '`; '</span>
|
674
|
-
<span class="ruby-comment cmt">#elsif rest[-1] == ?\n</span>
|
675
|
-
<span class="ruby-comment cmt"># rest.chomp!</span>
|
676
|
-
<span class="ruby-comment cmt"># @script << escape_str(rest) << @newlinestr << '`' << @newline</span>
|
677
|
-
<span class="ruby-comment cmt">#else</span>
|
678
|
-
<span class="ruby-comment cmt"># @script << escape_str(rest) << '`; '</span>
|
679
|
-
<span class="ruby-comment cmt">#end</span>
|
680
|
-
<span class="ruby-identifier">flag_newline</span> = <span class="ruby-identifier">input</span>[<span class="ruby-value">-1</span>] <span class="ruby-operator">==</span> <span class="ruby-value">?\n</span>
|
681
|
-
<span class="ruby-identifier">add_text</span>(<span class="ruby-identifier">rest</span>, <span class="ruby-keyword kw">true</span>)
|
682
|
-
<span class="ruby-identifier">stop_text_part</span>()
|
683
|
-
<span class="ruby-ivar">@script</span> <span class="ruby-operator"><<</span> (<span class="ruby-identifier">flag_newline</span> <span class="ruby-value">? </span><span class="ruby-ivar">@newline</span> <span class="ruby-operator">:</span> <span class="ruby-value str">'; '</span>)
|
684
|
-
<span class="ruby-keyword kw">end</span>
|
685
|
-
</pre>
|
686
|
-
</div>
|
687
|
-
</div>
|
688
|
-
</div>
|
689
|
-
|
690
|
-
<div id="method-M000054" class="method-detail">
|
691
|
-
<a name="M000054"></a>
|
692
|
-
|
693
|
-
<div class="method-heading">
|
694
|
-
<a href="#M000054" class="method-signature">
|
695
|
-
<span class="method-name">parse_stmts</span><span class="method-args">(input)</span>
|
696
|
-
</a>
|
697
|
-
</div>
|
698
|
-
|
699
|
-
<div class="method-description">
|
700
|
-
<p>
|
701
|
-
parse statements (’<?rb … ?>’)
|
702
|
-
</p>
|
703
|
-
<p><a class="source-toggle" href="#"
|
704
|
-
onclick="toggleCode('M000054-source');return false;">[Source]</a></p>
|
705
|
-
<div class="method-source-code" id="M000054-source">
|
706
|
-
<pre>
|
707
|
-
<span class="ruby-comment cmt"># File lib/tenjin.rb, line 402</span>
|
708
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">parse_stmts</span>(<span class="ruby-identifier">input</span>)
|
709
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">input</span>
|
710
|
-
<span class="ruby-identifier">is_bol</span> = <span class="ruby-keyword kw">true</span>
|
711
|
-
<span class="ruby-identifier">prev_rspace</span> = <span class="ruby-keyword kw">nil</span>
|
712
|
-
<span class="ruby-identifier">pos</span> = <span class="ruby-value">0</span>
|
713
|
-
<span class="ruby-identifier">input</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-identifier">stmt_pattern</span>()) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">mspace</span>, <span class="ruby-identifier">code</span>, <span class="ruby-identifier">rspace</span><span class="ruby-operator">|</span>
|
714
|
-
<span class="ruby-identifier">m</span> = <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">last_match</span>
|
715
|
-
<span class="ruby-identifier">text</span> = <span class="ruby-identifier">input</span>[<span class="ruby-identifier">pos</span>, <span class="ruby-identifier">m</span>.<span class="ruby-identifier">begin</span>(<span class="ruby-value">0</span>) <span class="ruby-operator">-</span> <span class="ruby-identifier">pos</span>]
|
716
|
-
<span class="ruby-identifier">pos</span> = <span class="ruby-identifier">m</span>.<span class="ruby-identifier">end</span>(<span class="ruby-value">0</span>)
|
717
|
-
<span class="ruby-comment cmt">## detect spaces at beginning of line</span>
|
718
|
-
<span class="ruby-identifier">lspace</span> = <span class="ruby-keyword kw">nil</span>
|
719
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">rspace</span>.<span class="ruby-identifier">nil?</span>
|
720
|
-
<span class="ruby-comment cmt"># nothing</span>
|
721
|
-
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">text</span>.<span class="ruby-identifier">empty?</span>
|
722
|
-
<span class="ruby-identifier">lspace</span> = <span class="ruby-value str">""</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">is_bol</span>
|
723
|
-
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">text</span>[<span class="ruby-value">-1</span>] <span class="ruby-operator">==</span> <span class="ruby-value">?\n</span>
|
724
|
-
<span class="ruby-identifier">lspace</span> = <span class="ruby-value str">""</span>
|
725
|
-
<span class="ruby-keyword kw">else</span>
|
726
|
-
<span class="ruby-identifier">rindex</span> = <span class="ruby-identifier">text</span>.<span class="ruby-identifier">rindex</span>(<span class="ruby-value">?\n</span>)
|
727
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">rindex</span>
|
728
|
-
<span class="ruby-identifier">s</span> = <span class="ruby-identifier">text</span>[<span class="ruby-identifier">rindex</span><span class="ruby-operator">+</span><span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-value">-1</span>]
|
729
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">s</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/\A[ \t]*\z/</span>
|
730
|
-
<span class="ruby-identifier">lspace</span> = <span class="ruby-identifier">s</span>
|
731
|
-
<span class="ruby-identifier">text</span> = <span class="ruby-identifier">text</span>[<span class="ruby-value">0</span><span class="ruby-operator">..</span><span class="ruby-identifier">rindex</span>]
|
732
|
-
<span class="ruby-comment cmt">#text[rindex+1..-1] = ''</span>
|
733
|
-
<span class="ruby-keyword kw">end</span>
|
734
|
-
<span class="ruby-keyword kw">else</span>
|
735
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">is_bol</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">text</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/\A[ \t]*\z/</span>
|
736
|
-
<span class="ruby-identifier">lspace</span> = <span class="ruby-identifier">text</span>
|
737
|
-
<span class="ruby-identifier">text</span> = <span class="ruby-keyword kw">nil</span>
|
738
|
-
<span class="ruby-comment cmt">#lspace = text.dup</span>
|
739
|
-
<span class="ruby-comment cmt">#text[0..-1] = ''</span>
|
740
|
-
<span class="ruby-keyword kw">end</span>
|
741
|
-
<span class="ruby-keyword kw">end</span>
|
742
|
-
<span class="ruby-keyword kw">end</span>
|
743
|
-
<span class="ruby-identifier">is_bol</span> = <span class="ruby-identifier">rspace</span> <span class="ruby-value">? </span><span class="ruby-keyword kw">true</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">false</span>
|
744
|
-
<span class="ruby-comment cmt">##</span>
|
745
|
-
<span class="ruby-identifier">text</span>.<span class="ruby-identifier">insert</span>(<span class="ruby-value">0</span>, <span class="ruby-identifier">prev_rspace</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">prev_rspace</span>
|
746
|
-
<span class="ruby-identifier">parse_exprs</span>(<span class="ruby-identifier">text</span>)
|
747
|
-
<span class="ruby-identifier">code</span>.<span class="ruby-identifier">insert</span>(<span class="ruby-value">0</span>, <span class="ruby-identifier">mspace</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">mspace</span> <span class="ruby-operator">!=</span> <span class="ruby-value str">' '</span>
|
748
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">lspace</span>
|
749
|
-
<span class="ruby-identifier">assert</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">rspace</span>.<span class="ruby-identifier">nil?</span>
|
750
|
-
<span class="ruby-identifier">code</span>.<span class="ruby-identifier">insert</span>(<span class="ruby-value">0</span>, <span class="ruby-identifier">lspace</span>)
|
751
|
-
<span class="ruby-identifier">code</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">rspace</span>
|
752
|
-
<span class="ruby-comment cmt">#add_stmt(code)</span>
|
753
|
-
<span class="ruby-identifier">prev_rspace</span> = <span class="ruby-keyword kw">nil</span>
|
754
|
-
<span class="ruby-keyword kw">else</span>
|
755
|
-
<span class="ruby-identifier">code</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">';'</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">code</span>[<span class="ruby-value">-1</span>] <span class="ruby-operator">==</span> <span class="ruby-value">?\n</span>
|
756
|
-
<span class="ruby-comment cmt">#add_stmt(code)</span>
|
757
|
-
<span class="ruby-identifier">prev_rspace</span> = <span class="ruby-identifier">rspace</span>
|
758
|
-
<span class="ruby-keyword kw">end</span>
|
759
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">code</span>
|
760
|
-
<span class="ruby-identifier">code</span> = <span class="ruby-identifier">statement_hook</span>(<span class="ruby-identifier">code</span>)
|
761
|
-
<span class="ruby-identifier">add_stmt</span>(<span class="ruby-identifier">code</span>)
|
762
|
-
<span class="ruby-keyword kw">end</span>
|
763
|
-
<span class="ruby-keyword kw">end</span>
|
764
|
-
<span class="ruby-comment cmt">#rest = $' || input</span>
|
765
|
-
<span class="ruby-identifier">rest</span> = <span class="ruby-identifier">pos</span> <span class="ruby-operator">></span> <span class="ruby-value">0</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">input</span>[<span class="ruby-identifier">pos</span><span class="ruby-operator">..</span><span class="ruby-value">-1</span>] <span class="ruby-operator">:</span> <span class="ruby-identifier">input</span>
|
766
|
-
<span class="ruby-identifier">rest</span>.<span class="ruby-identifier">insert</span>(<span class="ruby-value">0</span>, <span class="ruby-identifier">prev_rspace</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">prev_rspace</span>
|
767
|
-
<span class="ruby-identifier">parse_exprs</span>(<span class="ruby-identifier">rest</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">rest</span> <span class="ruby-operator">&&</span> <span class="ruby-operator">!</span><span class="ruby-identifier">rest</span>.<span class="ruby-identifier">empty?</span>
|
768
|
-
<span class="ruby-keyword kw">end</span>
|
769
|
-
</pre>
|
770
|
-
</div>
|
771
|
-
</div>
|
772
|
-
</div>
|
773
|
-
|
774
|
-
<div id="method-M000059" class="method-detail">
|
775
|
-
<a name="M000059"></a>
|
776
|
-
|
777
|
-
<div class="method-heading">
|
778
|
-
<a href="#M000059" class="method-signature">
|
779
|
-
<span class="method-name">start_text_part</span><span class="method-args">()</span>
|
780
|
-
</a>
|
781
|
-
</div>
|
782
|
-
|
783
|
-
<div class="method-description">
|
784
|
-
<p>
|
785
|
-
start text part
|
786
|
-
</p>
|
787
|
-
<p><a class="source-toggle" href="#"
|
788
|
-
onclick="toggleCode('M000059-source');return false;">[Source]</a></p>
|
789
|
-
<div class="method-source-code" id="M000059-source">
|
790
|
-
<pre>
|
791
|
-
<span class="ruby-comment cmt"># File lib/tenjin.rb, line 569</span>
|
792
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">start_text_part</span>()
|
793
|
-
<span class="ruby-ivar">@script</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">" _buf << %Q`"</span>
|
794
|
-
<span class="ruby-keyword kw">end</span>
|
795
|
-
</pre>
|
796
|
-
</div>
|
797
|
-
</div>
|
798
|
-
</div>
|
799
|
-
|
800
|
-
<div id="method-M000058" class="method-detail">
|
801
|
-
<a name="M000058"></a>
|
802
|
-
|
803
|
-
<div class="method-heading">
|
804
|
-
<a href="#M000058" class="method-signature">
|
805
|
-
<span class="method-name">statement_hook</span><span class="method-args">(stmt)</span>
|
806
|
-
</a>
|
807
|
-
</div>
|
808
|
-
|
809
|
-
<div class="method-description">
|
810
|
-
<p>
|
811
|
-
expand macros and parse ’#@ARGS’ in a statement.
|
812
|
-
</p>
|
813
|
-
<p><a class="source-toggle" href="#"
|
814
|
-
onclick="toggleCode('M000058-source');return false;">[Source]</a></p>
|
815
|
-
<div class="method-source-code" id="M000058-source">
|
816
|
-
<pre>
|
817
|
-
<span class="ruby-comment cmt"># File lib/tenjin.rb, line 510</span>
|
818
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">statement_hook</span>(<span class="ruby-identifier">stmt</span>)
|
819
|
-
<span class="ruby-comment cmt">## macro expantion</span>
|
820
|
-
<span class="ruby-comment cmt">#macro_pattern = /\A\s*(\w+)\((.*?)\);?(\s*)\z/</span>
|
821
|
-
<span class="ruby-comment cmt">#if macro_pattern =~ stmt</span>
|
822
|
-
<span class="ruby-comment cmt"># name = $1; arg = $2; rspace = $3</span>
|
823
|
-
<span class="ruby-comment cmt"># handler = get_macro_handler(name)</span>
|
824
|
-
<span class="ruby-comment cmt"># ret = handler ? handler.call(arg) + $3 : stmt</span>
|
825
|
-
<span class="ruby-comment cmt"># return ret</span>
|
826
|
-
<span class="ruby-comment cmt">#end</span>
|
827
|
-
<span class="ruby-comment cmt">## arguments declaration</span>
|
828
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@args</span>.<span class="ruby-identifier">nil?</span>
|
829
|
-
<span class="ruby-identifier">args_pattern</span> = <span class="ruby-regexp re">/\A *\#@ARGS([ \t]+(.*?))?(\s*)\z/</span> <span class="ruby-comment cmt">#</span>
|
830
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">args_pattern</span> <span class="ruby-operator">=~</span> <span class="ruby-identifier">stmt</span>
|
831
|
-
<span class="ruby-ivar">@args</span> = []
|
832
|
-
<span class="ruby-identifier">declares</span> = <span class="ruby-value str">''</span>
|
833
|
-
<span class="ruby-identifier">rspace</span> = <span class="ruby-identifier">$3</span>
|
834
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">$2</span>
|
835
|
-
<span class="ruby-keyword kw">for</span> <span class="ruby-identifier">s</span> <span class="ruby-keyword kw">in</span> <span class="ruby-identifier">$2</span>.<span class="ruby-identifier">split</span>(<span class="ruby-regexp re">/,/</span>)
|
836
|
-
<span class="ruby-identifier">arg</span> = <span class="ruby-identifier">s</span>.<span class="ruby-identifier">strip</span>()
|
837
|
-
<span class="ruby-keyword kw">next</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">s</span>.<span class="ruby-identifier">empty?</span>
|
838
|
-
<span class="ruby-identifier">arg</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/\A[a-zA-Z_]\w*\z/</span> <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">"#{arg}: invalid template argument."</span>)
|
839
|
-
<span class="ruby-ivar">@args</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">arg</span>
|
840
|
-
<span class="ruby-identifier">declares</span> <span class="ruby-operator"><<</span> <span class="ruby-node">" #{arg} = @#{arg};"</span>
|
841
|
-
<span class="ruby-keyword kw">end</span>
|
842
|
-
<span class="ruby-keyword kw">end</span>
|
843
|
-
<span class="ruby-identifier">declares</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">rspace</span>
|
844
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">declares</span>
|
845
|
-
<span class="ruby-keyword kw">end</span>
|
846
|
-
<span class="ruby-keyword kw">end</span>
|
847
|
-
<span class="ruby-comment cmt">##</span>
|
848
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">stmt</span>
|
849
|
-
<span class="ruby-keyword kw">end</span>
|
850
|
-
</pre>
|
851
|
-
</div>
|
852
|
-
</div>
|
853
|
-
</div>
|
854
|
-
|
855
|
-
<div id="method-M000053" class="method-detail">
|
856
|
-
<a name="M000053"></a>
|
857
|
-
|
858
|
-
<div class="method-heading">
|
859
|
-
<a href="#M000053" class="method-signature">
|
860
|
-
<span class="method-name">stmt_pattern</span><span class="method-args">()</span>
|
861
|
-
</a>
|
862
|
-
</div>
|
863
|
-
|
864
|
-
<div class="method-description">
|
865
|
-
<p><a class="source-toggle" href="#"
|
866
|
-
onclick="toggleCode('M000053-source');return false;">[Source]</a></p>
|
867
|
-
<div class="method-source-code" id="M000053-source">
|
868
|
-
<pre>
|
869
|
-
<span class="ruby-comment cmt"># File lib/tenjin.rb, line 397</span>
|
870
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">stmt_pattern</span>
|
871
|
-
<span class="ruby-constant">STMT_PATTERN</span>
|
872
|
-
<span class="ruby-keyword kw">end</span>
|
873
|
-
</pre>
|
874
|
-
</div>
|
875
|
-
</div>
|
876
|
-
</div>
|
877
|
-
|
878
|
-
<div id="method-M000060" class="method-detail">
|
879
|
-
<a name="M000060"></a>
|
880
|
-
|
881
|
-
<div class="method-heading">
|
882
|
-
<a href="#M000060" class="method-signature">
|
883
|
-
<span class="method-name">stop_text_part</span><span class="method-args">()</span>
|
884
|
-
</a>
|
885
|
-
</div>
|
886
|
-
|
887
|
-
<div class="method-description">
|
888
|
-
<p>
|
889
|
-
stop text part
|
890
|
-
</p>
|
891
|
-
<p><a class="source-toggle" href="#"
|
892
|
-
onclick="toggleCode('M000060-source');return false;">[Source]</a></p>
|
893
|
-
<div class="method-source-code" id="M000060-source">
|
894
|
-
<pre>
|
895
|
-
<span class="ruby-comment cmt"># File lib/tenjin.rb, line 574</span>
|
896
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">stop_text_part</span>()
|
897
|
-
<span class="ruby-ivar">@script</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">'`'</span>
|
898
|
-
<span class="ruby-keyword kw">end</span>
|
899
|
-
</pre>
|
900
|
-
</div>
|
901
|
-
</div>
|
902
|
-
</div>
|
903
|
-
|
904
|
-
|
905
|
-
</div>
|
906
|
-
|
907
|
-
|
908
|
-
</div>
|
909
|
-
|
910
|
-
|
911
|
-
<div id="validator-badges">
|
912
|
-
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
913
|
-
</div>
|
914
|
-
|
915
|
-
</body>
|
916
|
-
</html>
|