View

The abstract wrapper for views.

abstract
static if(isWebServer || !isWeb)
class View {}

Constructors

this
this(HttpClient client, string name)

Creates a new view.

this
this(string name)

Creates a new view.

Public Imports

diamond.unittesting
public import diamond.unittesting;
diamond.seo.schema
public import diamond.seo.schema : SchemaObject;
CSRF
public import CSRF = diamond.security.csrf;
diamond.extensions
public import diamond.extensions;

Members

Enums

FlashMessageType
enum FlashMessageType

Enumeration of flash messages.

Functions

action
string action(string actionName)

Gets a route that fits an action for the current route.

actionParams
string actionParams(string actionName, string[] params)

Gets a route that fits an action and parameters for the current route.

addPlaceholder
void addPlaceholder(string key, string value)

Adds a place holder to the view.

append
void append(T data)

Appends data to the view's result. This will append data to the current position. Generally this is not necessary, because of the template attributes such as @=

appendCSRFTokenField
void appendCSRFTokenField(string name, bool appendName)

Appends a hidden-field with a generated token that can be used for csrf protection.

asView
auto asView()

Gets th current view as a specific view.

asyncScript
void asyncScript(string file)

Inserts an asynchronous javascript file in a script tag.

clearCSRFToken
void clearCSRFToken()

Clears the current csrf token. This is recommended before generating CSRF token fields.

clearView
void clearView()

Clears the view result.

copyViewData
void copyViewData()

Copies the view data.

deferScript
void deferScript(string file)

Inserts a javascript file in a script tag after the page has loaded.

escape
void escape(T data)

Appends html escaped data to the view's result. This will append data to the current position. Generally this is not necessary, because of the template attributes such as @(), @$= etc.

flashMessage
void flashMessage(string identifier, string message, FlashMessageType type, size_t displayTime)

Creates a flash message.

generate
string generate(string sectionName)

Generates the result of the view. This is override by each view implementation.

getPlaceholder
string getPlaceholder(string key)

Gets a place holder of the view.

googleMeta
void googleMeta(string name, string description, string image)

Adds google meta tags.

meta
void meta(string name, string content)

Adds a meta tag.

openGraphGeneralMeta
void openGraphGeneralMeta(string title, string description, string image, string url, string siteName, string type)

Adds open graph general meta tags.

prepare
string prepare()

Prepares the view with its layout, placeholders etc.

render
void render(string name, string sectionName)

Will render another view into this one.

render
void render(string sectionName)

Will render another view into this one.

renderModel
void renderModel(TModel model, string sectionName)

Will render another view into this one.

retrieve
string retrieve(string name, string sectionName)

Retrieves the generated result of a view. This should generally only be used to render partial views into another view.

retrieve
string retrieve(string sectionName)

Retrieves the generated result of a view. This should generally only be used to render partial views into another view.

retrieveModel
string retrieveModel(TModel model, string sectionName)

Retrieves the generated result of a view. This should generally only be used to render partial views into another view.

schema
void schema(SchemaObject schemaObject)

Adds a structured data entry.

script
void script(string file)

Inserts a javascript file in a script tag.

twitterMeta
void twitterMeta(string card, string title, string description, string site, string image)

Adds twitter meta tags.

view
auto view(string name, bool checkRoute)

Retrieves a view by name. This wraps around getView.

viewRaw
auto viewRaw(bool checkRoute)

Retrieves a raw view by name. This wraps around getView.

Mixins

__anonymous
mixin ExtensionEmit!(ExtensionType.viewExtension, q{ mixin {{extensionEntry}}.extensions; })
Undocumented in source.

Properties

cacheTime
size_t cacheTime [@property setter]

Sets the time the view is statically cached.

cacheTime
size_t cacheTime [@property getter]

Gets the time the view is statically cached.

cached
bool cached [@property setter]

Sets a boolean determining whether the view can be cached or not.

cached
bool cached [@property getter]

Gets a boolean determining whether the view can be cached or not.

client
HttpClient client [@property getter]

Gets the client.

delayRender
bool delayRender [@property getter]

Gets a boolean determining whether the rendering is delayed.

delayRender
bool delayRender [@property setter]

Sets a boolean determining whether the rendering is delayed.

httpMethod
HttpMethod httpMethod [@property getter]

Gets the method.

isDefaultRoute
bool isDefaultRoute [@property getter]

Gets a boolean determining whether the route is the default route or not.

layoutName
string layoutName [@property getter]

Gets the layout name.

layoutName
string layoutName [@property setter]

Sets the layout name.

name
string name [@property getter]

Gets the name.

name
string name [@property setter]

Sets the name.

rawGenerate
bool rawGenerate [@property getter]

Gets a boolean determining whether the view generation is raw or if it should call controllers etc.

rawGenerate
bool rawGenerate [@property setter]

Sets a boolean determining whether the view generation is raw or if it should call controllers etc.

renderView
View renderView [@property getter]

Gets the view that's currently rendering the layout view.

renderView
View renderView [@property setter]

Sets a new render view.

route
Route route [@property getter]

Gets the route.

staticCache
bool staticCache [@property setter]

Sets a boolean determining wheter the view is statically cached or not.

staticCache
bool staticCache [@property getter]

Gets a boolean determining wheter the view is statically cached or not.

testing
bool testing [@property getter]

Gets a boolean determnining whether the request is a test or not.

Meta