Lasso Soft Inc. > Home

[output_capture]

Linkoutput_capture
AuthorMark Kawakami
CategoryOutput
Version8.x
LicensePublic Domain
Posted13 Feb 2006
Updated02 Mar 2006
More by this author...

Description

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

Sample Usage

[var('ret') = '']
[output_capture($ret)]

My name is [if(action_param('network') == 'FOX')]Judge[else(action_param('network') == 'NBC')]Earl[else]Slim Shady[/if].

[/output_capture] [$ret] now evaluates to:

My name is Earl

.

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.

// output_capture tag definition
define_tag('output_capture', -required='captureTo', -container);
	local('ret') = run_children;
	#captureTo = #ret;
/define_tag;

Comments

13 Feb 2006, Bil Corry

My bad

Sorry, it now works in LP8.1.

13 Feb 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.

13 Feb 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.

Please log in to comment

Subscribe to the LassoTalk mail list

LassoSoft Inc. > Home

 

 

©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft