| 1 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" |
| 2 |
"http://www.w3.org/TR/html4/loose.dtd"> |
| 3 |
<html lang='en'> |
| 4 |
|
| 5 |
<!-- |
| 6 |
Copyright (c) 1999-2010 by Digital Mars |
| 7 |
All Rights Reserved Written by Walter Bright |
| 8 |
http://www.digitalmars.com |
| 9 |
--> |
| 10 |
|
| 11 |
<head> |
| 12 |
<meta http-equiv="content-type" content="text/html; charset=utf-8" > |
| 13 |
<title>mustache - D Programming Language - Digital Mars</title> |
| 14 |
<link rel="stylesheet" type="text/css" href="../css/style.css"> |
| 15 |
|
| 16 |
<script type="text/javascript"> |
| 17 |
function listanchors() |
| 18 |
{ |
| 19 |
if (typeof inhibitQuickIndex !== 'undefined') return; |
| 20 |
var a = document.getElementById("quickindex"); |
| 21 |
if (!a) return; |
| 22 |
var newText = ""; |
| 23 |
var hash = new Array; |
| 24 |
var n = 0; |
| 25 |
var values = new Array; |
| 26 |
// List all anchors. |
| 27 |
for (var i = 0; i < document.anchors.length; i++) |
| 28 |
{ |
| 29 |
var a = document.anchors[i]; |
| 30 |
var text = a.name; |
| 31 |
if (hash[text] > 0) continue; |
| 32 |
hash[text] = 1; |
| 33 |
values[n++] = a.name |
| 34 |
} |
| 35 |
|
| 36 |
values.sort(); |
| 37 |
|
| 38 |
for(var i = 0; i < values.length; i++) { |
| 39 |
var a = values[i]; |
| 40 |
newText += ' \x3Ca href="\x23' + a + |
| 41 |
'"\x3E\x3Cspan class="d_psymbol"\x3E' + a + '\x3C/span\x3E\x3C/a\x3E'; |
| 42 |
} |
| 43 |
if (newText != "") newText = "\x3Cp\x3E\x3Cb\x3EJump to:\x3C/b\x3E" + newText + "\x3C/p\x3E"; |
| 44 |
var a = document.getElementById("quickindex"); |
| 45 |
a.innerHTML = newText; |
| 46 |
} |
| 47 |
</script> |
| 48 |
|
| 49 |
<script src="/js/hyphenate_selectively.js" type="text/javascript"></script> |
| 50 |
|
| 51 |
</head> |
| 52 |
|
| 53 |
<body onload="listanchors()" class='hyphenate'> |
| 54 |
|
| 55 |
<div id="top"> |
| 56 |
<div id="search-box"> |
| 57 |
<form method="get" action="http://google.com/search"> |
| 58 |
<img src="/images/search-left.gif" width="11" height="22" alt=""><input id="q" name="q"><input type="image" id="search-submit" name="submit" src="/images/search-button.gif"> |
| 59 |
<input type="hidden" id="domains" name="domains" value="d-programming-language.org"> |
| 60 |
<input type="hidden" id="sourceid" name="sourceid" value="google-search"> |
| 61 |
<div id="search-dropdown"> |
| 62 |
<select id="sitesearch" name="sitesearch" size="1"> |
| 63 |
<option value="d-programming-language.org">Entire D Site</option> |
| 64 |
<option value="d-programming-language.org/phobos">Library Reference</option> |
| 65 |
<option value="www.digitalmars.com/d/archives">Newsgroup Archives</option> |
| 66 |
</select> |
| 67 |
</div> |
| 68 |
</form> |
| 69 |
</div> |
| 70 |
<div id="header"> |
| 71 |
<a href="/"><img id="logo" width="125" height="95" border="0" alt="D Logo" src="/images/dlogo.png"></a> |
| 72 |
<a id="d-language" href="/">D Programming Language </a> |
| 73 |
</div> |
| 74 |
</div> |
| 75 |
|
| 76 |
<div id="navigation"> |
| 77 |
|
| 78 |
<div class="navblock"> |
| 79 |
<form method="get" action="http://www.google.com/search"> |
| 80 |
<div id="searchbox"> |
| 81 |
<input name="q" size="10" value="RTL Search" onFocus='if(this.value == "RTL Search"){this.value="";}'> |
| 82 |
<input type="hidden" name="domains" value="www.digitalmars.com"> |
| 83 |
<input type="hidden" name="sitesearch" value="www.digitalmars.com/d/2.0/phobos"> |
| 84 |
<input type="hidden" name="sourceid" value="google-search"> |
| 85 |
<input type="submit" name="submit" value="Go"> |
| 86 |
</div> |
| 87 |
</form> |
| 88 |
<div id="toctop"> |
| 89 |
<ul><li><a href="../index.html" title="D Programming Language">D</a></li> |
| 90 |
<li><a href="../spec.html" title="D Language Specification">Language</a></li> |
| 91 |
<li><a href="../phobos/index.html" title="D Runtime Library">Phobos</a></li> |
| 92 |
<li><a href="../phobos-prerelease/index.html" title="D Runtime Library (prerelease)">Phobos (prerelease)</a></li> |
| 93 |
<li><a href="../comparison.html" title="Language Comparisons">Comparisons</a></li> |
| 94 |
</ul> |
| 95 |
</div> |
| 96 |
</div> |
| 97 |
|
| 98 |
<div class="navblock"> |
| 99 |
<ul><li><a href="object.html" title="root of object hierarchy">object</a></li> |
| 100 |
</ul> |
| 101 |
<h2><a href="index.html#std" title="D standard modules">std</a></h2> |
| 102 |
<ul><li><a href="std_algorithm.html" title="General-purpose algorithms">std.algorithm</a></li> |
| 103 |
<li><a href="std_array.html" title="Array functions">std.array</a></li> |
| 104 |
<li><a href="std_ascii.html" title="Functions which operate on ASCII characters">std.ascii</a></li> |
| 105 |
<li><a href="std_base64.html" title="Encode/decode base64 format">std.base64</a></li> |
| 106 |
<li><a href="std_bigint.html" title="Arbitrary-precision ('bignum') arithmetic">std.bigint</a></li> |
| 107 |
<li><a href="std_bitmanip.html" title="Bit-level manipulation">std.bitmanip</a></li> |
| 108 |
<li><a href="std_compiler.html" title="Information about the D compiler implementation">std.compiler</a></li> |
| 109 |
<li><a href="std_complex.html" title="Complex numbers">std.complex</a></li> |
| 110 |
<li><a href="std_concurrency.html" title="Message Passing">std.concurrency</a></li> |
| 111 |
<li><a href="std_container.html" title="Containers">std.container</a></li> |
| 112 |
<li><a href="std_contracts.html" title="Think assert">std.contracts</a></li> |
| 113 |
<li><a href="std_conv.html" title="Conversion of strings to integers">std.conv</a></li> |
| 114 |
<li><a href="std_cpuid.html" title="CPU identification">std.cpuid</a></li> |
| 115 |
<li><a href="std_ctype.html" title="Simple character classification">std.ctype</a></li> |
| 116 |
<li><a href="std_date.html" title="Date and time functions">std.date</a></li> |
| 117 |
<li><a href="std_datetime.html" title="Date and time-related types and functions">std.datetime</a></li> |
| 118 |
<li><a href="std_demangle.html" title="Demangle D names">std.demangle</a></li> |
| 119 |
<li><a href="std_encoding.html" title="Character and string encoding">std.encoding</a></li> |
| 120 |
<li><a href="std_exception.html" title="Exceptions and error handling">std.exception</a></li> |
| 121 |
<li><a href="std_file.html" title="Basic file operations">std.file</a></li> |
| 122 |
<li><a href="std_format.html" title="Formatted conversions of values to strings">std.format</a></li> |
| 123 |
<li><a href="std_functional.html" title="functional">std.functional</a></li> |
| 124 |
<li><a href="std_getopt.html" title="Command line options">std.getopt</a></li> |
| 125 |
<li><a href="std_gregorian.html" title="Gregorian Calendar">std.gregorian</a></li> |
| 126 |
<li><a href="std_json.html" title="JSON reader">std.json</a></li> |
| 127 |
<li><a href="std_math.html" title="the usual math functions">std.math</a></li> |
| 128 |
<li><a href="std_mathspecial.html" title="mathematical special functions">std.mathspecial</a></li> |
| 129 |
<li><a href="std_md5.html" title="Compute MD5 digests">std.md5</a></li> |
| 130 |
<li><a href="std_metastrings.html" title="Metaprogramming with strings">std.metastrings</a></li> |
| 131 |
<li><a href="std_mmfile.html" title="Memory mapped files">std.mmfile</a></li> |
| 132 |
<li><a href="std_numeric.html" title="Numeric algorithms">std.numeric</a></li> |
| 133 |
<li><a href="std_outbuffer.html" title="Assemble data into an array of bytes">std.outbuffer</a></li> |
| 134 |
<li><a href="std_parallelism.html" title="High-level primitives for SMP parallelism">std.parallelism</a></li> |
| 135 |
<li><a href="std_path.html" title="Manipulate file names, path names, etc.">std.path</a></li> |
| 136 |
<li><a href="std_process.html" title="Create/destroy processes">std.process</a></li> |
| 137 |
<li><a href="std_random.html" title="Random number generation">std.random</a></li> |
| 138 |
<li><a href="std_range.html" title="Ranges">std.range</a></li> |
| 139 |
<li><a href="std_regex.html" title="regular expressions">std.regex</a></li> |
| 140 |
<li><a href="std_regexp.html" title="regular expressions (deprecated)">std.regexp</a></li> |
| 141 |
<li><a href="std_signals.html" title="Signals">std.signals</a></li> |
| 142 |
<li><a href="std_socket.html" title="Sockets">std.socket</a></li> |
| 143 |
<li><a href="std_socketstream.html" title="Stream for a blocking, connected Socket">std.socketstream</a></li> |
| 144 |
<li><a href="std_stdint.html" title="Integral types for various purposes">std.stdint</a></li> |
| 145 |
<li><a href="std_stdio.html" title="Standard I/O">std.stdio</a></li> |
| 146 |
<li><a href="std_cstream.html" title="Stream I/O">std.cstream</a></li> |
| 147 |
<li><a href="std_stream.html" title="Stream I/O">std.stream</a></li> |
| 148 |
<li><a href="std_string.html" title="Basic string operations">std.string</a></li> |
| 149 |
<li><a href="std_system.html" title="Inquire about the CPU, operating system">std.system</a></li> |
| 150 |
<li><a href="std_traits.html" title="Type traits">std.traits</a></li> |
| 151 |
<li><a href="std_typecons.html" title="Type constructors">std.typecons</a></li> |
| 152 |
<li><a href="std_typetuple.html" title="Type tuples">std.typetuple</a></li> |
| 153 |
<li><a href="std_uni.html" title="Unicode classification">std.uni</a></li> |
| 154 |
<li><a href="std_uri.html" title="Encode and decode Uniform Resource Identifiers (URIs)">std.uri</a></li> |
| 155 |
<li><a href="std_utf.html" title="Encode and decode utf character encodings">std.utf</a></li> |
| 156 |
<li><a href="std_variant.html" title="Stores all types in a uniform, dynamically-checked representation">std.variant</a></li> |
| 157 |
<li><a href="std_xml.html" title="XML file processing">std.xml</a></li> |
| 158 |
<li><a href="std_zip.html" title="Read/write zip archives">std.zip</a></li> |
| 159 |
<li><a href="std_zlib.html" title="Compression / Decompression of data">std.zlib</a></li> |
| 160 |
<li><a href="std_c_fenv.html" title="Floating point environment">std.c.fenv</a></li> |
| 161 |
<li><a href="std_c_locale.html" title="Locale">std.c.locale</a></li> |
| 162 |
<li><a href="std_c_math.html" title="Math">std.c.math</a></li> |
| 163 |
<li><a href="std_c_process.html" title="Process">std.c.process</a></li> |
| 164 |
<li><a href="std_c_stdarg.html" title="Variadic arguments">std.c.stdarg</a></li> |
| 165 |
<li><a href="std_c_stddef.html" title="Standard definitions">std.c.stddef</a></li> |
| 166 |
<li><a href="std_c_stdio.html" title="Standard I/O">std.c.stdio</a></li> |
| 167 |
<li><a href="std_c_stdlib.html" title="Standard library">std.c.stdlib</a></li> |
| 168 |
<li><a href="std_c_string.html" title="Strings">std.c.string</a></li> |
| 169 |
<li><a href="std_c_time.html" title="Time">std.c.time</a></li> |
| 170 |
<li><a href="std_c_wcharh.html" title="Wide characters">std.c.wcharh</a></li> |
| 171 |
<li><a href="std_net_isemail.html" title="Validate e-mail addresses">std.net.isemail</a></li> |
| 172 |
<li><a href="std_windows_charset.html" title="Conversion to/from Windows character sets">std.windows.charset</a></li> |
| 173 |
<li><a href="index.html#std_windows" title="Modules specific to Windows">std.windows</a></li> |
| 174 |
<li><a href="index.html#std_linux" title="Modules specific to Windows">std.linux</a></li> |
| 175 |
<li><a href="index.html#std_c_windows" title="C Windows API">std.c.windows</a></li> |
| 176 |
<li><a href="index.html#std_c_linux" title="C Linux API">std.c.linux</a></li> |
| 177 |
</ul> |
| 178 |
<h2><a href="index.html#etc" title="D etc modules">etc</a></h2> |
| 179 |
<ul><li><a href="etc_c_curl.html" title="Interface to libcurl library">etc.c.curl</a></li> |
| 180 |
<li><a href="etc_c_zlib.html" title="Interface to zlib library">etc.c.zlib</a></li> |
| 181 |
</ul> |
| 182 |
<h2><a href="index.html#core" title="D core modules">core</a></h2> |
| 183 |
<ul><li><a href="core_atomic.html" title="Atomic operations">core.atomic</a></li> |
| 184 |
<li><a href="core_bitop.html" title="Bitwise operations">core.bitop</a></li> |
| 185 |
<li><a href="core_cpuid.html" title="CPU identification">core.cpuid</a></li> |
| 186 |
<li><a href="core_exception.html" title="Root of exception hierarchy">core.exception</a></li> |
| 187 |
<li><a href="core_memory.html" title="Interface to memory management">core.memory</a></li> |
| 188 |
<li><a href="core_runtime.html" title="Interface to D runtime library internals">core.runtime</a></li> |
| 189 |
<li><a href="core_thread.html" title="Thread management">core.thread</a></li> |
| 190 |
<li><a href="core_time.html" title="Core time functionality">core.time</a></li> |
| 191 |
<li><a href="core_vararg.html" title="Variable function arguments">core.vararg</a></li> |
| 192 |
<li><a href="core_sync_barrier.html" title="Synchronizing progress of a group of threads">core.sync.barrier</a></li> |
| 193 |
<li><a href="core_sync_condition.html" title="Synchronized condition checking">core.sync.condition</a></li> |
| 194 |
<li><a href="core_sync_config.html" title="Stuff for core.sync">core.sync.config</a></li> |
| 195 |
<li><a href="core_sync_exception.html" title="SyncException">core.sync.exception</a></li> |
| 196 |
<li><a href="core_sync_mutex.html" title="Mutexes">core.sync.mutex</a></li> |
| 197 |
<li><a href="core_sync_rwmutex.html" title="R/W mutually exclusive access">core.sync.rwmutex</a></li> |
| 198 |
<li><a href="core_sync_semaphore.html" title="Semaphores">core.sync.semaphore</a></li> |
| 199 |
</ul> |
| 200 |
</div> |
| 201 |
</div> |
| 202 |
<div id="content"> |
| 203 |
<h1>mustache</h1> |
| 204 |
<div id=quickindex class=quickindex></div> |
| 205 |
<!-- Generated by Ddoc from src/mustache.d --> |
| 206 |
Mustache template engine for D |
| 207 |
<p></p> |
| 208 |
Implemented according to <a href="http://mustache.github.com/mustache.5.html">mustach(5)</a>. |
| 209 |
|
| 210 |
<p></p> |
| 211 |
<b>License:</b><br><a href="http://www.boost.org/LICENSE_1_0.txt">Boost License 1.0</a>. |
| 212 |
<p></p> |
| 213 |
<b>Authors:</b><br>Masahiro Nakagawa<p></p> |
| 214 |
|
| 215 |
<dl><dt class="d_decl">class <a name="MustacheException"></a><span class="ddoc_psymbol">MustacheException</span>: object.Exception; |
| 216 |
</dt> |
| 217 |
<dd>Exception for Mustache<p></p> |
| 218 |
|
| 219 |
</dd> |
| 220 |
<dt class="d_decl">struct <a name="MustacheEngine"></a><span class="ddoc_psymbol">MustacheEngine</span>(String = string) if (isSomeString!(String)); |
| 221 |
</dt> |
| 222 |
<dd>Core implementation of Mustache |
| 223 |
<p></p> |
| 224 |
<span class="d_param">String</span> parameter means a string type to render. |
| 225 |
|
| 226 |
<p></p> |
| 227 |
<b>Example:</b><br> |
| 228 |
<pre class="d_code"> <span class="d_keyword">alias</span> <span class="d_psymbol">MustacheEngine</span>!(string) Mustache; |
| 229 |
|
| 230 |
Mustache mustache; |
| 231 |
<span class="d_keyword">auto</span> context = <span class="d_keyword">new</span> Mustache.Context; |
| 232 |
|
| 233 |
context[<span class="d_string">"name"</span>] = <span class="d_string">"Chris"</span>; |
| 234 |
context[<span class="d_string">"value"</span>] = 10000; |
| 235 |
context[<span class="d_string">"taxed_value"</span>] = 10000 - (10000 * 0.4); |
| 236 |
context.useSection(<span class="d_string">"in_ca"</span>); |
| 237 |
|
| 238 |
write(mustache.render(<span class="d_string">"sample"</span>, context)); |
| 239 |
</pre> |
| 240 |
sample.mustache: |
| 241 |
<pre class="d_code"> Hello {{name}} |
| 242 |
You have just won ${{value}}! |
| 243 |
{{#in_ca}} |
| 244 |
Well, ${{taxed_value}}, after taxes. |
| 245 |
{{/in_ca}} |
| 246 |
</pre> |
| 247 |
<p></p> |
| 248 |
<b>Output:</b><br> |
| 249 |
<pre class="d_code"> Hello Chris |
| 250 |
You have just won 0000! |
| 251 |
Well, 000, after taxes. |
| 252 |
</pre> |
| 253 |
<p></p> |
| 254 |
|
| 255 |
<dl><dt class="d_decl">enum <a name="CacheLevel"></a><span class="ddoc_psymbol">CacheLevel</span>; |
| 256 |
</dt> |
| 257 |
<dd>Cache level for compile result<p></p> |
| 258 |
|
| 259 |
<dl><dt class="d_decl"><a name="no"></a><span class="ddoc_psymbol">no</span></dt> |
| 260 |
<dd>No caching<p></p> |
| 261 |
|
| 262 |
</dd> |
| 263 |
<dt class="d_decl"><a name="check"></a><span class="ddoc_psymbol">check</span></dt> |
| 264 |
<dd>Caches compiled result and checks the freshness of template<p></p> |
| 265 |
|
| 266 |
</dd> |
| 267 |
<dt class="d_decl"><a name="once"></a><span class="ddoc_psymbol">once</span></dt> |
| 268 |
<dd>Caches compiled result but not check the freshness of template<p></p> |
| 269 |
|
| 270 |
</dd> |
| 271 |
</dl> |
| 272 |
</dd> |
| 273 |
<dt class="d_decl">struct <a name="Option"></a><span class="ddoc_psymbol">Option</span>; |
| 274 |
</dt> |
| 275 |
<dd>Options for rendering<p></p> |
| 276 |
|
| 277 |
<dl><dt class="d_decl">string <a name="ext"></a><span class="ddoc_psymbol">ext</span>; |
| 278 |
</dt> |
| 279 |
<dd>template file extenstion<p></p> |
| 280 |
|
| 281 |
</dd> |
| 282 |
<dt class="d_decl">string <a name="path"></a><span class="ddoc_psymbol">path</span>; |
| 283 |
</dt> |
| 284 |
<dd>root <a name="path"></a><span class="ddoc_psymbol">path</span> for template file searching<p></p> |
| 285 |
|
| 286 |
</dd> |
| 287 |
<dt class="d_decl">CacheLevel <a name="level"></a><span class="ddoc_psymbol">level</span>; |
| 288 |
</dt> |
| 289 |
<dd>See CacheLevel<p></p> |
| 290 |
|
| 291 |
</dd> |
| 292 |
<dt class="d_decl">Handler <a name="handler"></a><span class="ddoc_psymbol">handler</span>; |
| 293 |
</dt> |
| 294 |
<dd>Callback <a name="handler"></a><span class="ddoc_psymbol">handler</span> for unknown name<p></p> |
| 295 |
|
| 296 |
</dd> |
| 297 |
</dl> |
| 298 |
</dd> |
| 299 |
<dt class="d_decl">class <a name="Context"></a><span class="ddoc_psymbol">Context</span>; |
| 300 |
</dt> |
| 301 |
<dd>Mustache context for setting values |
| 302 |
<p></p> |
| 303 |
<b>Variable:</b><br> |
| 304 |
<pre class="d_code"> <span class="d_comment">//{{name}} to "Chris" |
| 305 |
</span> context[<span class="d_string">"name"</span>] = <span class="d_string">"Chirs"</span> |
| 306 |
</pre> |
| 307 |
|
| 308 |
Lists section("addSubContext" name is drived from ctemplate's API): |
| 309 |
<pre class="d_code"> <span class="d_comment">//{{#repo}} |
| 310 |
</span> <span class="d_comment">//<b>{{name}}</b> |
| 311 |
</span> <span class="d_comment">//{{/repo}} |
| 312 |
</span> <span class="d_comment">// to |
| 313 |
</span> <span class="d_comment">//<b>resque</b> |
| 314 |
</span> <span class="d_comment">//<b>hub</b> |
| 315 |
</span> <span class="d_comment">//<b>rip</b> |
| 316 |
</span> <span class="d_keyword">foreach</span> (name; [<span class="d_string">"resque"</span>, <span class="d_string">"hub"</span>, <span class="d_string">"rip"</span>]) { |
| 317 |
<span class="d_keyword">auto</span> sub = context.addSubContext(<span class="d_string">"repo"</span>); |
| 318 |
sub[<span class="d_string">"name"</span>] = name; |
| 319 |
} |
| 320 |
</pre> |
| 321 |
|
| 322 |
Variable section: |
| 323 |
<pre class="d_code"> <span class="d_comment">//{{#person?}}Hi {{name}}{{/person?}} to "Hi Jon" |
| 324 |
</span> context[<span class="d_string">"person?"</span>] = [<span class="d_string">"name"</span> : <span class="d_string">"Jon"</span>]; |
| 325 |
</pre> |
| 326 |
|
| 327 |
Lambdas section: |
| 328 |
<pre class="d_code"> <span class="d_comment">//{{#wrapped}}awesome{{/wrapped}} to "<b>awesome</b>" |
| 329 |
</span> context[<span class="d_string">"Wrapped"</span>] = (string str) { <span class="d_keyword">return</span> <span class="d_string">"<b>"</span> ~ str ~ <span class="d_string">"</b>"</span>; }; |
| 330 |
</pre> |
| 331 |
|
| 332 |
Inverted section: |
| 333 |
<pre class="d_code"> <span class="d_comment">//{{#repo}}<b>{{name}}</b>{{/repo}} |
| 334 |
</span> <span class="d_comment">//{{^repo}}No repos :({{/repo}} |
| 335 |
</span> <span class="d_comment">// to |
| 336 |
</span> <span class="d_comment">//No repos :( |
| 337 |
</span> context[<span class="d_string">"foo"</span>] = <span class="d_string">"bar"</span>; <span class="d_comment">// not set to "repo" |
| 338 |
</span></pre> |
| 339 |
<p></p> |
| 340 |
|
| 341 |
<dl><dt class="d_decl">const nothrow String <a name="opIndex"></a><span class="ddoc_psymbol">opIndex</span>(in String <i>key</i>); |
| 342 |
</dt> |
| 343 |
<dd>Gets <span class="d_param"><i>key</i></span>'s value. This method does not search Section. |
| 344 |
<p></p> |
| 345 |
<b>Parameters:</b><table class=parms><tr><td valign=top>String <i>key</i></td> |
| 346 |
<td valign=top><i>key</i> string to search</td></tr> |
| 347 |
</table><p></p> |
| 348 |
<b>Returns:</b><br>a <span class="d_param"><i>key</i></span> associated value. |
| 349 |
|
| 350 |
<p></p> |
| 351 |
<b>Throws:</b><br>a RangeError if <span class="d_param"><i>key</i></span> does not exist.<p></p> |
| 352 |
|
| 353 |
</dd> |
| 354 |
<dt class="d_decl">void <a name="opIndexAssign"></a><span class="ddoc_psymbol">opIndexAssign</span>(T)(T <i>value</i>, in String <i>key</i>); |
| 355 |
</dt> |
| 356 |
<dd>Assigns <span class="d_param">value</span>(automatically convert to String) to <span class="d_param">key</span> field. |
| 357 |
<p></p> |
| 358 |
If you try to assign associative array or delegate, |
| 359 |
This method assigns <span class="d_param">value</span> as Section. |
| 360 |
|
| 361 |
<p></p> |
| 362 |
<b>Parameters:</b><table class=parms><tr><td valign=top>value</td> |
| 363 |
<td valign=top>some type value to assign</td></tr> |
| 364 |
<tr><td valign=top>key</td> |
| 365 |
<td valign=top>key string to assign</td></tr> |
| 366 |
</table><p></p> |
| 367 |
|
| 368 |
</dd> |
| 369 |
<dt class="d_decl">void <a name="useSection"></a><span class="ddoc_psymbol">useSection</span>(in String <i>key</i>); |
| 370 |
</dt> |
| 371 |
<dd>Enable <span class="d_param"><i>key</i></span>'s section. |
| 372 |
<p></p> |
| 373 |
<b>Parameters:</b><table class=parms><tr><td valign=top>String <i>key</i></td> |
| 374 |
<td valign=top><i>key</i> string to enable</td></tr> |
| 375 |
</table><p></p> |
| 376 |
<b>NOTE:</b><br> |
| 377 |
I don't like this method, but D's typing can't well-handle Ruby's typing.<p></p> |
| 378 |
|
| 379 |
</dd> |
| 380 |
<dt class="d_decl">Context <a name="addSubContext"></a><span class="ddoc_psymbol">addSubContext</span>(in String <i>key</i>, lazy size_t <i>size</i> = 1); |
| 381 |
</dt> |
| 382 |
<dd>Adds new context to <span class="d_param"><i>key</i></span>'s section. This method overwrites with |
| 383 |
list type if you already assigned other type to <span class="d_param"><i>key</i></span>'s section. |
| 384 |
<p></p> |
| 385 |
<b>Parameters:</b><table class=parms><tr><td valign=top>String <i>key</i></td> |
| 386 |
<td valign=top><i>key</i> string to add</td></tr> |
| 387 |
<tr><td valign=top>size_t <i>size</i></td> |
| 388 |
<td valign=top>reserve <i>size</i> for avoiding reallocation</td></tr> |
| 389 |
</table><p></p> |
| 390 |
<b>Returns:</b><br>new Context object that added to <span class="d_param"><i>key</i></span> section list.<p></p> |
| 391 |
|
| 392 |
</dd> |
| 393 |
</dl> |
| 394 |
</dd> |
| 395 |
<dt class="d_decl">const const(string) <a name="ext"></a><span class="ddoc_psymbol">ext</span>(); |
| 396 |
<br>void <a name="ext"></a><span class="ddoc_psymbol">ext</span>(string <a name="ext"></a><span class="ddoc_psymbol">ext</span>); |
| 397 |
</dt> |
| 398 |
<dd>Property for template extenstion<p></p> |
| 399 |
|
| 400 |
</dd> |
| 401 |
<dt class="d_decl">const const(string) <a name="path"></a><span class="ddoc_psymbol">path</span>(); |
| 402 |
<br>void <a name="path"></a><span class="ddoc_psymbol">path</span>(string <a name="path"></a><span class="ddoc_psymbol">path</span>); |
| 403 |
</dt> |
| 404 |
<dd>Property for template searche <a name="path"></a><span class="ddoc_psymbol">path</span><p></p> |
| 405 |
|
| 406 |
</dd> |
| 407 |
<dt class="d_decl">const const(CacheLevel) <a name="level"></a><span class="ddoc_psymbol">level</span>(); |
| 408 |
<br>void <a name="level"></a><span class="ddoc_psymbol">level</span>(CacheLevel <a name="level"></a><span class="ddoc_psymbol">level</span>); |
| 409 |
</dt> |
| 410 |
<dd>Property for cache <a name="level"></a><span class="ddoc_psymbol">level</span><p></p> |
| 411 |
|
| 412 |
</dd> |
| 413 |
<dt class="d_decl">const const(Handler) <a name="handler"></a><span class="ddoc_psymbol">handler</span>(); |
| 414 |
<br>void <a name="handler"></a><span class="ddoc_psymbol">handler</span>(Handler <a name="handler"></a><span class="ddoc_psymbol">handler</span>); |
| 415 |
</dt> |
| 416 |
<dd>Property for callback <a name="handler"></a><span class="ddoc_psymbol">handler</span><p></p> |
| 417 |
|
| 418 |
</dd> |
| 419 |
<dt class="d_decl">String <a name="render"></a><span class="ddoc_psymbol">render</span>(in string <i>name</i>, in Context <i>context</i>); |
| 420 |
</dt> |
| 421 |
<dd>Renders <span class="d_param"><i>name</i></span> template with <span class="d_param"><i>context</i></span>. |
| 422 |
<p></p> |
| 423 |
This method stores compile result in memory if you set check or once CacheLevel. |
| 424 |
|
| 425 |
<p></p> |
| 426 |
<b>Parameters:</b><table class=parms><tr><td valign=top>string <i>name</i></td> |
| 427 |
<td valign=top>template <i>name</i> without extenstion</td></tr> |
| 428 |
<tr><td valign=top>Context <i>context</i></td> |
| 429 |
<td valign=top>Mustache <i>context</i> for rendering</td></tr> |
| 430 |
</table><p></p> |
| 431 |
<b>Returns:</b><br>rendered result. |
| 432 |
|
| 433 |
<p></p> |
| 434 |
<b>Throws:</b><br>object.Exception if String alignment is mismatched from template file.<p></p> |
| 435 |
|
| 436 |
</dd> |
| 437 |
<dt class="d_decl">String <a name="renderString"></a><span class="ddoc_psymbol">renderString</span>(in String <i>src</i>, in Context <i>context</i>); |
| 438 |
</dt> |
| 439 |
<dd>string version of <span class="d_inlinecode">render</span>.<p></p> |
| 440 |
|
| 441 |
</dd> |
| 442 |
</dl> |
| 443 |
</dd> |
| 444 |
</dl> |
| 445 |
|
| 446 |
|
| 447 |
<br><br> |
| 448 |
<br><br> |
| 449 |
<!-- Google ad --> |
| 450 |
<script type="text/javascript"><!-- |
| 451 |
/**/google_ad_client = "pub-5628673096434613"; |
| 452 |
/**/google_ad_width = 728; |
| 453 |
/**/google_ad_height = 90; |
| 454 |
/**/google_ad_format = "728x90_as"; |
| 455 |
/**/google_ad_channel ="6203743411"; |
| 456 |
/**/google_page_url = document.location; |
| 457 |
//--></script> |
| 458 |
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> |
| 459 |
</script> |
| 460 |
</div> |
| 461 |
|
| 462 |
|
| 463 |
<div id="copyright"> |
| 464 |
Copyright Masahiro Nakagawa 2011-. |
| 465 |
| |
| 466 |
Page generated by <a href="http://www.digitalmars.com/d/2.0/ddoc.html">Ddoc</a>. |
| 467 |
</div> |
| 468 |
|
| 469 |
</body> |
| 470 |
</html> |