Fossil SCM
Added th1_ob.wiki embedded doc.
Commit
905f67d0d36fe13350ae0914754c8de3bca04a9d
Parent
f2d87242503d7a7…
1 file changed
+40
+40
| --- a/www/th1_ob.wiki | ||
| +++ b/www/th1_ob.wiki | ||
| @@ -0,0 +1,40 @@ | ||
| 1 | +<h1>TH1 "ob" (Output Buffering) API</h1> | |
| 2 | + | |
| 3 | +The "ob" API mimics the | |
| 4 | +[http://php.net/manual/en/function.ob-start.php|PHP output buffering] fairly closely, | |
| 5 | +and provides these features: | |
| 6 | + | |
| 7 | + * Redirect output from <tt>puts</tt> and friends to a buffer. | |
| 8 | + * Fetch the buffer as a string or discard it (as you wish). | |
| 9 | + * Supports nesting buffering arbitrarily deep, but each level which gets opened must also be closed by the scripter. | |
| 10 | + | |
| 11 | +Example usage: | |
| 12 | + | |
| 13 | +<nowiki><pre> | |
| 14 | +<th1> | |
| 15 | +pustart | |
| 16 | +# all output until the next ob start|end gets collected | |
| 17 | +# in a buffer... | |
| 18 | +</th1> | |
| 19 | + | |
| 20 | +this is buffered | |
| 21 | + | |
| 22 | +<th1> | |
| 23 | +puts "current buffer level = " [ob level] "\n" | |
| 24 | +puts "this part is also collected in the buffer." | |
| 25 | + | |
| 26 | +# Collect the buffer's contents: | |
| 27 | +set buf [ob get end] | |
| 28 | +# That is equivalent to: end | |
| 29 | + | |
| 30 | +puts "\nThis is now unbuffered, but we buffered: $buf\n" | |
| 31 | +</th1> | |
| 32 | +</pre></nowiki> | |
| 33 | + | |
| 34 | +The functions are summarized below... | |
| 35 | + | |
| 36 | +<h2>ob start</h2> | |
| 37 | + | |
| 38 | +portant that everypushes a level of buffering onto the buffer stack, such that | |
| 39 | +future calls which generate output through the th1-internal mechanism will have it | |
| 40 | +transparently redirected to the cu |
| --- a/www/th1_ob.wiki | |
| +++ b/www/th1_ob.wiki | |
| @@ -0,0 +1,40 @@ | |
| --- a/www/th1_ob.wiki | |
| +++ b/www/th1_ob.wiki | |
| @@ -0,0 +1,40 @@ | |
| 1 | <h1>TH1 "ob" (Output Buffering) API</h1> |
| 2 | |
| 3 | The "ob" API mimics the |
| 4 | [http://php.net/manual/en/function.ob-start.php|PHP output buffering] fairly closely, |
| 5 | and provides these features: |
| 6 | |
| 7 | * Redirect output from <tt>puts</tt> and friends to a buffer. |
| 8 | * Fetch the buffer as a string or discard it (as you wish). |
| 9 | * Supports nesting buffering arbitrarily deep, but each level which gets opened must also be closed by the scripter. |
| 10 | |
| 11 | Example usage: |
| 12 | |
| 13 | <nowiki><pre> |
| 14 | <th1> |
| 15 | pustart |
| 16 | # all output until the next ob start|end gets collected |
| 17 | # in a buffer... |
| 18 | </th1> |
| 19 | |
| 20 | this is buffered |
| 21 | |
| 22 | <th1> |
| 23 | puts "current buffer level = " [ob level] "\n" |
| 24 | puts "this part is also collected in the buffer." |
| 25 | |
| 26 | # Collect the buffer's contents: |
| 27 | set buf [ob get end] |
| 28 | # That is equivalent to: end |
| 29 | |
| 30 | puts "\nThis is now unbuffered, but we buffered: $buf\n" |
| 31 | </th1> |
| 32 | </pre></nowiki> |
| 33 | |
| 34 | The functions are summarized below... |
| 35 | |
| 36 | <h2>ob start</h2> |
| 37 | |
| 38 | portant that everypushes a level of buffering onto the buffer stack, such that |
| 39 | future calls which generate output through the th1-internal mechanism will have it |
| 40 | transparently redirected to the cu |