Docs - parse
07/31/2010: SUIT 2.0.1 and Rulebox 1.1.0 released.
Available Since: SUIT (2.0.0)
Generate the tree from the tokens and string. The tree will show how the string has been broken up and how to transform it.
{
"closed": true // Shown if this node has been closed.
"contents":
[
"string",
{
"closed": true
"contents": ["etc."],
"create": " condition=\"var\"", // The contents of the create rule if applicable.
"createrule": "[if condition=\"var\"]", // The whole create rule statement if applicable.
"rule": "[if]" // The type of rule
},
"etc."
] // This node's branches.
}
Hello, <strong>[var]username[/var]</strong>!
<?php
require 'suit.class.php';
require 'templating.class.php';
$suit = new SUIT();
$templating = new Templating($suit);
$templating->var->username = 'Brandon';
$tokens = $suit->tokens($templating->rules, $template);
$tree = $suit->parse($templating->rules, $tokens, $template);
/*
Result: array
(
'closed' => true,
'contents' => array
(
'Hello, <strong>',
array
(
'closed' => true,
'contents' => array('username'),
'rule' => '[var]'
),
'</strong>!'
)
)
*/
?>
import suit
from rulebox import templating
templating.var.username = 'Brandon'
tokens = suit.tokens(templating.rules, template)
tree = suit.parse(templating.rules, tokens, template)
# Result: {
# 'closed': True,
# 'contents':
# [
# 'Hello, <strong>',
# {
# 'closed': True,
# 'contents': ['username'],
# 'rule': '[var]'
# },
# '</strong>!'
# ]
# }





