Docs - tokens
12/27/2015: SUIT Framework is no longer actively maintained.
Available Since: SUIT (2.0.0)
Generate the tokens from the string. Tokens contain the different open and close strings and their positions.
A list of dicts with the following format:
Key | Description | ||||||
---|---|---|---|---|---|---|---|
bounds |
dict
|
||||||
string | str: The located string. | ||||||
type | str: The type, options being open, close, or flat. |
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);
/*
Result: array
(
array
(
'bounds' => array
(
'end' => 20,
'start' => 15
),
'string' => '[var]',
'type' => 'open'
),
array
(
'bounds' => array
(
'end' => 34,
'start' => 28
),
'string' => '[/var]',
'type' => 'close'
)
)
*/
?>
import suit
from rulebox import templating
templating.var.username = 'Brandon'
tokens = suit.tokens(templating.rules, template)
# Result: [
# {
# 'bounds':
# {
# 'end': 20,
# 'start': 15
# },
# 'string': '[var]',
# 'type': 'open'
# },
# {
# 'bounds':
# {
# 'end': 34,
# 'start': 28
# },
# 'string': '[/var]',
# 'type': 'close'
# }
# ]