PupcakeResponseRender
Pupcake Response Render is a Plugin to allow the response object in Plugin Express Plugin to render different types of templates., (*1)
Installation:
install package "Pupcake/ResponseRender" using composer (http://getcomposer.org/)
Usage
We can simply call render([viewpath], [data]) on the response object, (*2)
usePlugin("Pupcake.ResponseRender");
$app->on("node.edit.form.fields", function(){
$fields = array();
$fields[] = array('type' => 'textfield', 'id' => 'title');
$fields[] = array('type' => 'textbox', 'id' => 'body');
$fields[] = array('type' => 'textbox', 'id' => 'summary');
$fields[] = array('type' => 'image_upload', 'id' => 'logo', 'maxsize' => '2MB');
$fields[] = array('type' => 'embed_video', 'id' => 'youtube-video', 'provider' => 'youtube');
return $fields;
});
$app->get("node/:id/edit", function($req, $res) use ($app) {
$data = array();
$data['fields'] = $app->trigger("node.edit.form.fields"); //the node edit form creation
$res->render("../views/index.tpl.php", $data);
});
$app->run();
```
Then here is the corresponding index.tpl.php
```html
{ ?>
<h1><?php echo $fields; ?></h1>