This documentation refers to a Gravstrap obsolete release. Please consider to upgrade to the new release

The Gravstrap Alert component handles the Bootstrap alert component.

The alert component is defined by the following Yaml code:

gravstrap:
    alert:
        alert1:
            #from_file: alert.markdown
            #type: danger | success / info / warning 
            body: Oh snap! Change a few things up and try submitting again.
            #attributes:
            #    id: myAlert
            #    class: alert-dismissible

This code must be added to the page where you need to display the component.

from_file property [optional]

The from_file optional property defines the file which contains the contents for each alert element. This file must be added under the page where the component is displayed and it is structured as follows:

[SECTION body]

Oh snap! You got an error!

Change this and that and try again. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Cras mattis consectetur purus sit amet fermentum.

[Take this action](#) {.btn .btn-danger}
[Or do this](#) {.btn .btn-default}

[/SECTION]

This file must contain a single section called body.

If you need to add more alerts and you want to define for each alert a markdown content, you must add a markdown file for all the alerts you want to handle.

type property [optional]

The type optional property defines the alert type. You can choose one from the following accepted values: danger, success, info, warning. Danger is the default value for this component.

body property [optional]

The body property defines a simple content for the alert body. When you define both the body and the from_file properties, the latter one is ignored.

attributes property [optional]

The attributes property defines an array of html tags you can add to the alert component.

Render the alert component

Add the following code to the template where you need to render the alert component:

{{ gravstrap.alert1 }}

Next Post Previous Post