Page Blocks

Hosting sponsored by:

Point In Space

 

API: Cnfg

Filename:
fwpCnfg_loadVars.cnfg

Released With:
5.0.0

Current Version:
1.3.0

Status: Active

Min Lasso Tested: 8.1.0

Max Lasso Tested: 8.5.3

Related:

Still don't get it?

Check out the talk list archives, or join and ask your questions.

Documentation Error or Request?

Email documentation corrections or comments

API Reference

fwpCnfg_loadVars (Tag)

Description

Loads a configuration file which is structured with each line being a separate declaration of a varName=varValue pair. The line endings are normalized, empty and comment elements are removed, and the data is then split to become a Lasso array type with each line as a single array element (not a Lasso pair). Each line is then processed to set a $var or #local variable using the name and value.

The tag searches the /site/configs/ folder and the current /_resources/configs/ folder. Alternately, a full file pathname can be given to load a specific file not in the usual /configs/ folder.

This tag is essentially a macro for the sequence of tags fwpCnfg_loadFile, fwpCnfg_deComment, fwpCnfg_splitLines, and fwpCnfg_makeVars. The end result is the creation of all the variables specified in the file(s).

Comments in the configuration lines can begin with # or //, empty lines are allowed, and the Lasso container [output_none]...[/output_none] can wrap the file contents. All of these non-data lines will be ignored.

Syntax

fwpCnfg_loadVars: fileName, -asLocals, -removeWhiteSpace;

Configuration file format:

[output_none]
# comments like this
// or like this
# blank lines allowed too

# shape stuff
color = Banana Yellow
shape = trapezoid

# pet stuff
pet=dog
petName=Spike
[/output_none]

Parameters & Member Tags

file (unnamed) = required : either a complete filename with extension or a full pathname. If a file name is specified without any path component, the tag will search the /site/configs/ folder and the current /_resources/configs/ folder. If a file with a path is specified, the complete virtual host root relative path must be specified, and the tag will load that one specific file.

-asLocals|-intoLocals|-makeLocals = optional : if specified, makes local variables instead of page variables. (Previous -locals param name is deprecated).

-removeWhiteSpace = optional : if specified, removes spaces and tabs surrounding the = or === of each line, leaving any spaces in the string after the pair delimiter. (Previous -despace param name is deprecated).

-withoutCaching (no value) = optional : add this param to prevent the caching of the config file data. The file is cached prior to final parsing into vars. The only reason to not have the file cached is if the content is expected to change often, and each call to load it should reload it directly from disk. This would require thread-safe operations by the application to do that. (Previous -nocache param is deprecated).

Examples

fwpCnfg_loadVars:'custom.cnfg';

fwpCnfg_loadVars:'custom.cnfg', -asLocals;

fwpCnfg_loadVars:'/nonstandard/config/path/custom.cnfg';

© 2002-2012, pageblocks.org