Esempio n. 1
0
        return join(' ', $this->contents);
    }
}
function do_echo($token)
{
    return new EchoNode(py_slice(explode(' ', $token->contents), 1));
}
$lib = new Library();
$lib->tag('echo', function ($parser, $token) {
    return do_echo($token);
});
$lib->tag('other_echo', function ($parser, $token) {
    return do_echo($token);
});
$lib->filter('upper', function ($value) {
    return strtoupper($value);
});
DjaBase::$libraries['testtags'] = $lib;
/*
 * Helper objects for template tests
 */
class SomeException extends Exception
{
    public $silent_variable_failure = True;
}
class SomeOtherException extends Exception
{
}
class ContextStackException extends Exception
{
}
Esempio n. 2
0
<?php

$lib = new Library();
// TODO implement stringfilter() if required.
/*
 * STRINGS
 */
//stringfilter
$lib->filter('addslashes', function ($value) {
    $value = str_replace('\\', '\\\\', $value);
    $value = str_replace('"', '\\"', $value);
    $value = str_replace("'", "\\'", $value);
    return $value;
}, array('is_safe' => True));
//stringfilter
$lib->filter('capfirst', function ($value) {
    return ucfirst($value);
}, array('is_safe' => True));
//stringfilter
$lib->filter('escapejs', function ($value) {
    return escapejs($value);
});
//stringfilter
$lib->filter('fix_ampersands', function ($value) {
    return preg_replace('~&(?!(\\w+|#\\d+);)~', '&amp;', $value);
}, array('is_safe' => True));
//stringfilter
$lib->filter('floatformat', function ($text, $arg = -1) {
    $input_val = (string) $text;
    $input_val = round($input_val, 1);
    return $input_val;