[output_capture]

Description

Link: [output_capture]
Author: Mark Kawakami
Category: Output
Version: 8.x
License: Public Domain
Posted: Feb. 13, 2006
Updated: Mar. 02, 2006
More by this author...
The basic method to get custom tags to output text and html is to build a string that returns your desired output, which works fine for small to medium chunks of code, but can be a pain for longer and more complex output. The purpose of this code is to take the output that would ordinarily be generated by a block of Lasso code and capture it to a variable, rather than outputting it directly to the page (or discarding it as is the case in custom tags). UPDATE: According to the comments, this may require Lasso 8.1 or higher

Parameters

-captureTo string, required This MUST be a variable declared elsewhere

Sample Usage

[var('ret') = '']
[output_capture($ret)]
<p>My name is [if(action_param('network') == 'FOX')]Judge[else(action_param('network') == 'NBC')]Earl[else]Slim Shady[/if].</p>
[/output_capture]

[$ret] now evaluates to: 
<p>My name is Earl</p>.
						

Source Code

Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.
1
2
3
4
5
6
// output_capture tag definition
define_tag('output_capture', -required='captureTo', -container);
	local('ret') = run_children;
	#captureTo = #ret;
/define_tag;

 

Comments

02/13/2006, Bil Corry
My bad
Sorry, it now works in LP8.1.
02/13/2006, Mark Kawakami
Are you sure about that?
It works on my test pages just fine, and I definitely haven't had it run at startup. I'll admit my experience with container tags is limited, but I can't seem to find a problem with defining the tag at runtime.
02/13/2006, Bil Corry
Using -container tags in LP8
For LP8, -container tags must be loaded in LassoStartup. You can not define them on the page that calls them.
Email:


Password:



Newest

Most Popular

Support tagSwap.net