src/View/BasicViewAbstract.php
public function addJsVar($vars, $value, $encode = false) {
        if (is_array($vars)) {
            foreach ($vars as $key => $value) {
                // if JSONencode it's enable then is because it doesn't want json_encode.
                $this->addJsVar($key, $value);
            }
        } else { // apply the logic
            $this->scriptVars = $this->scriptVars . "var $vars = " . ($encode ? json_encode($value) : $value) . ";";
        }
    }
public function addJsVar($vars, $value, $encode = false) {
        if (is_array($vars)) {
            foreach ($vars as $key => $value) {
                // if JSONencode it's enable then is because it doesn't want json_encode.
                $this->addJsVar($key, $value);
            }
        } else { // apply the logic
            $this->scriptVars = $this->scriptVars . "var $vars = " . ($encode ? json_encode($value) : $value) . ";";
        }
    }
Add a global JS variable to the view

@param mixed $vars array(variable_name => value, ...) or simply the
variable name. If $value happens to be a number (or something else you
don't want to "json_encode()", set $encode = FALSE
@param string $value
@param bool $encode = TRUE. If we don't want to encode some variable,
it is mandatory to add them one by one, under the pattern
addJsVar( $varName, $varValue, FALSE )
@note remember that if $foo is a string, then json_encode($var) === $var