Mannequin

Configuration

Mannequin configuration lives in the .mannequin.php at the root of your project. You should create this file, starting from the following example:

/**
 * Create a finder to search and list the static HTML files.
 */
$htmlFiles = Finder::create()
    ->files()
    ->in(__DIR__.'/html')
    ->name('*.html');

$htmlExtension = new HtmlExtension([
    'files' => $htmlFiles,
    'root' => __DIR__,
]);

/*
 * Create and return the configuration.  Don't forget to return it!
 */
return MannequinConfig::create()
    // JS and CSS can either be local (relative paths from the root),
    // or remote (absolute URLs)
    ->setGlobalJs(['https://cdnjs.cloudflare.com/ajax/libs/foundation/6.4.1/js/foundation.min.js'])
    ->setGlobalCss(['https://cdnjs.cloudflare.com/ajax/libs/foundation/6.4.1/css/foundation.css'])
    ->addExtension($htmlExtension);

HTML Configuration

The HtmlExtension is what tells Mannequin how to access your Twig templates. The mandatory arguments are the finder and the twig_root, but you can pass in twig_options as well:

<?php

$twigExtension = new HtmlExtension([
    // A Symfony Finder object.
    'finder' => $htmlFiles,
    // The path to your 'root' directory. This is used
    // to convert absolute paths into relative ones.
    'root' => __DIR__
]);

For more documentation on the Finder, see the Symfony Finder documentation.

Mannequin Config

The MannequinConfig class handles configuration for Mannequin in general (the non-Drupal parts). The configuration has a number of methods you can use to define your setup:

<?php

$config = MannequinConfig::create();

// Add an extension to the Mannequin configuration:
$config->addExtension($drupalExtension);

// Set the CSS files that are used for every component.  CSS can be referenced
// using a relative path, in which case it will be looked up
// relative to your .mannequin.php, or an absolute URL.
$config->setGlobalCss([
    'themes/mytheme/css/theme.css',
    'http://example.com/theme.css',
]);

// Set the JS files that are used for every component.  JS can be referenced
// using a relative path, in which case it will be looked up
// relative to your .mannequin.php, or an absolute URL.
$config->setGlobalJs([
    'themes/mytheme/js/theme.js',
    'http://example.com/theme.js'
]);