Wiki source code of BlogPostLayoutMacros
Hide last authors
| author | version | line-number | content |
|---|---|---|---|
| |
1.1 | 1 | {{velocity output='false'}} |
| 2 | #** | ||
| 3 | * Extract the layout parameters from a string. | ||
| 4 | * | ||
| 5 | * @param layoutParamsString The string representation of the layout parameters. | ||
| 6 | * It should contain a String following this format "paramName1=Value1|paramName2=Value2|...|paramNameK=ValueK" | ||
| 7 | * @param layoutsParameters The resulting layout parameters Map. | ||
| 8 | *### | ||
| 9 | #macro(extractLayoutParametersFromString $layoutParamsString $layoutsParameters) | ||
| 10 | #set ($layoutsParameters = $NULL) | ||
| 11 | #set ($macro.layoutParams = {}) | ||
| 12 | #if ("$!layoutParamsString" != '') | ||
| 13 | #set ($macro.paramsArr = $layoutParamsString.split('\|')) | ||
| 14 | #foreach ($item in $macro.paramsArr) | ||
| 15 | #set ($itemSplit = $item.split('=')) | ||
| 16 | #if ($itemSplit.size() == 2) | ||
| 17 | #set ($discard = $macro.layoutParams.put($itemSplit[0].trim(), $itemSplit[1].trim())) | ||
| 18 | #end | ||
| 19 | #end | ||
| 20 | #end | ||
| 21 | #setVariable("$layoutsParameters" $macro.layoutParams) | ||
| 22 | #end | ||
| 23 | {{/velocity}} | ||
| 24 |