/** * Bind the given array of variables to the view. * * @param array $variables */ public function put(array $variables) { // First, we have to translate the variables // to something JS-friendly. $js = $this->buildJavaScriptSyntax($variables); // And then we'll actually bind those // variables to the view. $this->viewBinder->bind($js); }
/** * Bind given array of variables to view * * @param array $vars */ public function put(array $vars) { // First, we have to translate the // variables to something JS-friendly. $js = $this->buildJavaScriptSyntax($vars); // This is what handles the process of binding // our JS vars to the view/page. $this->viewBinder->bind($js); }
/** * Bind the given array of variables to the view. * */ public function put() { $arguments = func_get_args(); if (is_array($arguments[0])) { $variables = $arguments[0]; } elseif (count($arguments) == 2) { $variables = [$arguments[0] => $arguments[1]]; } else { throw new Exception('Try JavaScript::put(["foo" => "bar"]'); } // First, we have to translate the variables // to something JS-friendly. $js = $this->buildJavaScriptSyntax($variables); // And then we'll actually bind those // variables to the view. $this->viewBinder->bind($js); return $js; }