get($args)); }; } public static function jsonAccess() { return function ($template, $context, $args, $source) { $parts = explode(".", $args); if (count($parts) != 2) { return "Invalid use of json-access"; } $data = json_decode($context->get($parts[0]), true); return $data[$parts[1]]; }; } public static function processFlex() { return function ($template, $context, $args, $source) { $output = ""; if (!is_iterable($context->get($args))) { return "Sorry, the item you passed to the flex helper is not iterable."; } $groups = $context->get($args); foreach ($groups as $g) { $output .= site()->render($g["tpl"], $g); } return $output; }; } public static function nl2br() { return function ($template, $context, $args, $source) { return nl2br($context->get($args)); }; } private static function getFromBuffer($func) { ob_start(); $func(); $output = ob_get_clean(); return $output; } }