Skip to content

Commit b85c5f2

Browse files
committed
Ubiquity renderView (for jQuery compilation)
1 parent 9673ecd commit b85c5f2

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

Ajax/JsUtils.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public function config($config=NULL) {
169169

170170
/**
171171
* @param array $params ['debug'=>true,'defer'=>false,'ajaxTransition'=>null,'beforeCompileHtml'=>null,'semantic'=>false,'bootstrap'=>false]
172-
* @param mixed $injected optional param for Symfony
172+
* @param mixed $injected optional param for Symfony/Ubiquity
173173
*/
174174
public function __construct($params=array(),$injected=NULL) {
175175
$defaults=['debug'=>true,'defer'=>false,'ajaxTransition'=>null];

Ajax/php/ubiquity/JsUtils.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,22 @@ public function renderContent($initialControllerInstance,$viewName, $params=NULL
3535
public function fromDispatcher($dispatcher){
3636
return Startup::$urlParts;
3737
}
38+
39+
/**
40+
* Performs jQuery compilation and displays a view
41+
* @param string $viewName
42+
* @param mixed $parameters Variable or associative array to pass to the view <br> If a variable is passed, it will have the name <b> $ data </ b> in the view, <br>
43+
* If an associative array is passed, the view retrieves variables from the table's key names
44+
* @param boolean $asString If true, the view is not displayed but returned as a string (usable in a variable)
45+
*/
46+
public function renderView($viewName,$parameters=[],$asString=false){
47+
if(isset($this->injected)){
48+
$view=$this->injected->getView();
49+
$this->compile($view);
50+
if (isset($parameters))
51+
$this->view->setVars($parameters);
52+
return $this->view->render($viewName, $asString);
53+
}
54+
throw new \Exception(get_class()." instance is not properly instancied : you omitted the second parameter \$controller!");
55+
}
3856
}

0 commit comments

Comments
 (0)