CAROLINA DOCS


Assets

The "assets" app provides some static asset files and templates that can be published into a project directory and serves static files as "/assets".

Publishable Files

Assets

The "assets" app has static asset files that can be published into your project directory with the following command:

node . publish --assets assets

That command will place the following directories into assets/:

  • bootstrap/: The dist directory from bootstrap.
  • bootswatch/: The dist directory from bootstrap.
  • fontawesome/: The dist directory from @fortawesome/free.
  • jquery: The dist directory from jquery.

They will be served by default under "/assets", so the bootstrap CSS file would be available at "/assets/bootstrap/css/bootstrap.min.css".

Templates

The "assets" app has template files that can be published into your project directory wiht the following command:

node . publish --templates assets

That command will write some templates into templates/carolina/.

The template file carolina/base.pug is a basic base template that you can use. It has some basic meta tags, including one that tracks the router's mount point and another that adds the CSRF token, and a block for css, title, body, and js.

The template file carolina/bootstrap_base.pug extends that and adds bootstrap CSS and JS files as well as JQuery.

The carolina/includes directory contains some templates you can include in your templates. You should include by relative path within the templates directory.

The file carolina/includes/csrf_input.pug creates a hidden form input that sends the correct CSRF token with the form with the name "_csrf". This is automatically found by the CSRF middleware and checked (if CSRF is applied).

Example:

form

include '../path/to/carolina/includes/csrf_input'

input(type="text" name="username")

The file carolina/includes/bootstrap_flash_message.pug adds bootstrap alerts containing any current flash messages from the flash middleware.

Router

The router defined by the "assets" app simply serves the assets/ directory as static files. It's mount point is determined by the urls configuration in config/routes.js, and is "/assets" by default.


CAROLINA DOCS