cutelyst 4.3.0
A C++ Web Framework built on top of Qt, using the simple approach of Catalyst (Perl) framework.

Available view plugins for Cutelyst that render output. More...

Collaboration diagram for View:

Classes

class  Cutelyst::CuteleeView
 A view that renders templates using Cutelee engine. More...
 
class  Cutelyst::ViewEmail
 A view that sends stash data via e-mail. More...
 
class  Cutelyst::ViewEmailTemplate
 A view that renders stash data using another view and sends it via e-mail. More...
 
class  Cutelyst::ViewJson
 A view that returns stash data in JSON format. More...
 

Detailed Description

View plugins for Cutelyst are subclasses of View and render output for displaying or serving to the user agent. They can for example render HTML pages using template engines like Cutelee or create and sending e-mails or return JSON data.

Cutelyst already ships with different views that most easily can by called by the RenderView action when already registered in your reimplementation of Application::init(). You can create different views distinguished by names that can be load for different areas of your application. You can for example use a CuteleeView for your HTML website routes and a ViewJson for your API routes.

Default view

Adding a view with an empty name makes it the default view. Everywhere where no view name is explicitely specified, the default view will be used.

Registering views

Views should be registered in your reimplementation of Application::init(). You can specify names for your views when registering them that can be used to load different views for different parts of your application. A nameless view would be the default view for your application.

#include <Cutelyst/Plugins/View/Cutelee/cuteleeview.h>
#include <Cutelyst/Plugins/View/JSON/viewjson.h>
using namespace Cutelyst;
bool MyApp::init()
{
// other initialization stuff
// ...
// registering a Cutelee view as default view
auto cuteleeView = new CuteleeView(this);
cuteleeView->setIncludePaths({"/path/to/my/template/files"});
// registering a JSON view with the name "json"
auto jsonView = new ViewJson(this, "json");
jsonView->setExposeStash("myjsonkey");
// ...
}
A view that renders templates using Cutelee engine.
A view that returns stash data in JSON format.
Definition viewjson.h:26
The Cutelyst namespace holds all public Cutelyst API.

Later in your code you can use the RenderView action to load the views.

#include <Cutelyst/Controller>
using namespace Cutelyst;
class Root : public Controller
{
// ...
private:
// will use the default view to render output
C_ATTR(End, :ActionClass("RenderView"))
void End(Context *c);
};
class Api : public Controller
{
// ...
private:
// will use the "json" view to render output
C_ATTR(End, :ActionClass("RenderView") :View("json"))
void End(Context *c);
};
The Cutelyst Context.
Definition context.h:42
Cutelyst Controller base class.
Definition controller.h:56
Abstract View component for Cutelyst.
Definition view.h:25