[include_once]

Description

Link: [include_once]
Author: Jason Huck
Category: Include
Version: 8.x
License:
Posted: Oct. 26, 2005
Updated: Jan. 16, 2006
More by this author...
Includes the specified file only if it has not already been included using this tag. Based on this discussion from Lasso Talk.

Requires [file_pathfromroot], available here.

Parameters

none


Sample Usage

include_once('/path/to/file.inc');
						

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
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
define_tag(
	'once',
	-namespace='include_',
	-priority='replace',
	-description='Includes the specified file only if it has not already been included.'
);
	fail_if(
		!params->size || !params->first->isa('string'),
		-1,
		'[include_once] requires a file path as a parameter.'
	);
	
	local('path') = file_pathfromroot(params->first);		
	!var_defined('included_files') ? var('included_files' = set);		
	
	if($included_files !>> #path);
		$included_files->insert(#path);
		return(include(#path));
	/if;		
/define_tag;

 

Related Tags



Comments

none

Email:


Password:



Newest

Most Popular