API: Cnfg
Filename:
fwpCnfg_splitBlocks.ctag
Released With:
5.1.5
Current Version:
1.1
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
Takes a typical PageBlocks config block and breaks it into a map. The resulting map is typically further processed by one of the other split tags based on the value of each map item, but most commonly the splitLabels tag.
varName = fwpCnfg_splitBlocks: varName;
varName = fwpCnfg_splitBlocks: varName, -asArray;
block (unnamed) = required : literal string data or a string variable.
-asArray = optional : include this param if the text is to be split into an array instead of a map
A block that looks like this
{{blockA:
label1___ value1
label2___ value2
}}
// unnamed block
{{
labelA___ valueA
labelB___ valueB
}}
{{blockB:
label3___ value3
label4___ value4
}}
is returned like this
map: (blockA)=(label1___\tvalue1\rlabel2___\tvalue2), (2)=(labelA___\tvalueA\rlabelB___\tvalueB) (blockB)=(label3___\tvalue3\rlabel4___\tvalue4)
Unnamed blocks are returned with a numerical value equivalent to the iterate loop_count at the time the block was parsed.
<?lassoscript
//............................................................................
//
// pageblocks: (c) 2002-2007 http://www.pageblocks.org/
//
//............................................................................
/*
{fileName= fwpCnfg_splitBlocks.ctag }
{rsrcType= tag }
{rsrcName= fwpCnfg_splitBlocks }
{rsrcHTTP= www.pageblocks.org/refc/fwpCnfg_splitBlocks }
{lassoVrsnMin= 8.1.0 }
{lassoVrsnMax= 8.5.3 }
{author= Greg Willits }
{authorEmail= subscribe to pbTalk at www.pageblocks.org/talk/ }
{authorHTTP= www.pageblocks.org }
{desc= Converts a series of config blocks into
an array of Lasso pairs. }
{maintvsrn= 1.1.0 }
{maintrelease= 5.2.0 }
{maintdate= 2007-06-09}
{maintauthor= Greg Willits }
{maintnotes= updated debug and error handling systems,
changed some internal vars for better readability }
{maintvsrn= 1.0 }
{maintrelease= 5.1.5 }
{maintdate= 2007-01-02 }
{maintauthor= Greg Willits }
{maintnotes= initial release }
*/
//.............................................................................
define_tag:'fwpCnfg_splitBlocks', -priority='replace',
-required = 'blocks';
// -asArray
($fw_debug >= fw_kChatty) ? $fw_tagTracer->(add:'fwpCnfg_splitBlocks');
local:
'splitResults' = map,
'configData' = #blocks,
'thisBlock' = string,
'blockName' = string,
'blockData' = string;
(params >> '-asArray')
? #splitResults = array;
if: #configData;
if: ((#configData->type != 'string') && (#configData->type != 'bytes'));
$fw_error->(insert:'5201'='fwpCnfg_splitBlocks');
$fw_debug ? $fw_apiError->(insert:'5241'=(#blocks->type));
$fw_debug ? $fw_tagTracer->(add:'fwpCnfg_splitBlocks', -ERROR = 'input was not a string or bytes');
$fw_criticalLog ? log_critical:'pbError : input to fwpCnfg_splitBlocks was not a string or bytes';
else;
(#configData = (string_findRegExp:#configData, -find='{{[\\s\\S]+?}}'));
iterate: #configData, #thisBlock;
#blockName = (string_findRegExp: #thisBlock, -find='{{([\\w]+?):')->last;
!#blockName ? #blockName = loop_count;
#blockData = (string_findRegExp: #thisBlock, -find='{{(?:\\w+\\:\\s*|\\s*)([\\s\\S]+?)}}')->last;
#blockData->trim;
#splitResults->(insert: #blockName = #blockData);
/iterate;
return: #splitResults;
/if;
else;
($fw_debug >= fw_kChatty) ? $fw_tagTracer->(add:'fwpCnfg_splitBlocks', -status = 'input was empty');
/if;
/define_tag;
?>
© 2002-2010, pageblocks.org