1
<?xml version="1.0" encoding="iso-8859-1"?>
3
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
6
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
8
<title>Module: Erubis::BiPatternEnhancer</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">
15
function popupCode( url ) {
16
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
19
function toggleCode( id ) {
20
if ( document.getElementById )
21
elem = document.getElementById( id );
22
else if ( document.all )
23
elem = eval( "document.all." + id );
27
elemStyle = elem.style;
29
if ( elemStyle.display != "block" ) {
30
elemStyle.display = "block"
32
elemStyle.display = "none"
38
// Make codeblocks hidden by default
39
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
49
<div id="classHeader">
50
<table class="header-table">
51
<tr class="top-aligned-row">
52
<td><strong>Module</strong></td>
53
<td class="class-name-in-header">Erubis::BiPatternEnhancer</td>
55
<tr class="top-aligned-row">
56
<td><strong>In:</strong></td>
58
<a href="../../files/erubis/enhancer_rb.html">
67
<!-- banner header -->
69
<div id="bodyContent">
73
<div id="contextContent">
75
<div id="description">
77
enable to use other embedded expression pattern (default is ’\[=
81
notice! this is an experimental. spec may change in the future.
88
<% for item in list %>
89
<%= item %> : <%== item %>
90
[= item =] : [== item =]
95
include BiPatternEnhancer
97
eruby = BiPatternEruby.new(input, :bipattern=>'\[= =\]')
98
list = ['<a>', 'b&b', '"c"']
99
print eruby.result(binding())
102
<a> : &lt;a&gt;
103
<a> : &lt;a&gt;
104
b&b : b&amp;b
105
b&b : b&amp;b
106
"c" : &quot;c&quot;
107
"c" : &quot;c&quot;
110
this is language independent.
118
<div id="method-list">
119
<h3 class="section-bar">Methods</h3>
121
<div class="name-list">
122
<a href="#M000153">add_text</a>
123
<a href="#M000152">new</a>
141
<!-- if method_list -->
143
<h3 class="section-bar">Public Class methods</h3>
145
<div id="method-M000152" class="method-detail">
146
<a name="M000152"></a>
148
<div class="method-heading">
149
<a href="#M000152" class="method-signature">
150
<span class="method-name">new</span><span class="method-args">(input, properties={})</span>
154
<div class="method-description">
155
<p><a class="source-toggle" href="#"
156
onclick="toggleCode('M000152-source');return false;">[Source]</a></p>
157
<div class="method-source-code" id="M000152-source">
159
<span class="ruby-comment cmt"># File erubis/enhancer.rb, line 408</span>
160
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">input</span>, <span class="ruby-identifier">properties</span>={})
161
<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">bipattern</span> = <span class="ruby-identifier">properties</span>[<span class="ruby-identifier">:bipattern</span>] <span class="ruby-comment cmt"># or '\$\{ \}'</span>
162
<span class="ruby-keyword kw">super</span>
163
<span class="ruby-keyword kw">end</span>
169
<h3 class="section-bar">Public Instance methods</h3>
171
<div id="method-M000153" class="method-detail">
172
<a name="M000153"></a>
174
<div class="method-heading">
175
<a href="#M000153" class="method-signature">
176
<span class="method-name">add_text</span><span class="method-args">(src, text)</span>
180
<div class="method-description">
181
<p><a class="source-toggle" href="#"
182
onclick="toggleCode('M000153-source');return false;">[Source]</a></p>
183
<div class="method-source-code" id="M000153-source">
185
<span class="ruby-comment cmt"># File erubis/enhancer.rb, line 420</span>
186
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_text</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">text</span>)
187
<span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">text</span>
188
<span class="ruby-identifier">m</span> = <span class="ruby-keyword kw">nil</span>
189
<span class="ruby-identifier">text</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-ivar">@bipattern_regexp</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">txt</span>, <span class="ruby-identifier">indicator</span>, <span class="ruby-identifier">code</span><span class="ruby-operator">|</span>
190
<span class="ruby-identifier">m</span> = <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">last_match</span>
191
<span class="ruby-keyword kw">super</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">txt</span>)
192
<span class="ruby-identifier">add_expr</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">code</span>, <span class="ruby-value str">'='</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">indicator</span>)
193
<span class="ruby-keyword kw">end</span>
194
<span class="ruby-comment cmt">#rest = $' || text # ruby1.8</span>
195
<span class="ruby-identifier">rest</span> = <span class="ruby-identifier">m</span> <span class="ruby-value">? </span><span class="ruby-identifier">text</span>[<span class="ruby-identifier">m</span>.<span class="ruby-identifier">end</span>(<span class="ruby-value">0</span>)<span class="ruby-operator">..</span><span class="ruby-value">-1</span>] <span class="ruby-operator">:</span> <span class="ruby-identifier">text</span> <span class="ruby-comment cmt"># ruby1.9</span>
196
<span class="ruby-keyword kw">super</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">rest</span>)
197
<span class="ruby-keyword kw">end</span>
210
<div id="validator-badges">
211
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
b'\\ No newline at end of file'