SUIT Framework

Scripting Using Integrated Templates

Docs - SLACKS

12/27/2015: SUIT Framework is no longer actively maintained.

SLACKS takes a SUIT generated log, which contains information on how the execute function works, and formats it to show the user how it transformed the template. In order to permit SLACKS to access this log, instead of calling execute and printing the result, you must use the following snippet.

PHP
<?php
// Execute the string.
$string = $suit->execute($rules, $string);
// Check if POST or GET data have been sent for SLACKS.
if ((array_key_exists('slacks', $_POST) && $_POST['slacks']) || (array_key_exists('slacks', $_GET) && $_GET['slacks']))
{
    // JSON encode the log.
    $slacks = json_encode($suit->log);
    // Set the headers to prompt a download of a .json file.
    header('Pragma: public');
    header('Expires: 0');
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    header('Content-type: text/json');
    header('Content-Disposition: attachment; filename=slacks.json');
    header('Content-Length: ' . strlen($slacks));
    // Print the log.
    echo $slacks;
}
else
{
    // Print the string normally.
    echo $string;
}
?>
Python
import json
# Execute the string.
string = suit.execute(rules, string)
# Check if POST or GET data have been sent for SLACKS.
if 'slacks' in request.params:
    # JSON encode the log.
    slacks = json.dumps(suit.log, separators=(',', ':'))
    # Set the headers to prompt a download of a .json file.
    response.headerlist = [
        ('Pragma', 'public'),
        ('Expires', '0'),
        (
            'Cache-Control',
            'must-revalidate, post-check=0, pre-check=0'
        ),
        ('Content-type', 'text/json'),
        ('Content-Disposition', 'attachment; filename=slacks.json'),
        ('Content-Length', len(slacks))
    ]
    # Print the log.
    print slacks
else:
    # Print the string normally.
    print string
# Only include the following if this is running on a constant Python process.
suit.log = {
    "contents": [],
    "hash": {},
}