Novices Plagiarizing Mozart

    This package has been deprecated

    Author message:

    This package has been renamed. Please use @frctl/consolidate-adapter instead

    @frctl/consolidate-engine

    0.4.0 • Public • Published

    Consolidate Engine

    Generic template engine handler for Fractal, powered by consolidate.js.

    This engine is currently very experimental. If a specific Fractal template engine handler for your desired language is available then it is recommended to use that instead of this one as it will likely be easier to use and configure than this generic handler.

    Currently specific template engine handlers have been implemented for:

    Note: Due to the way that Consolidate handles loading of templates, this engine cannot be used for rendering pages, only components.

    Usage

    This engine comes pre-installed with Fractal, so there is no need to install it separately. However you will need to install whichever template engine you want to use via NPM.

    As an example, to use Swig templates, first install swig:

    npm i swig --save

    Then add configuration details into your fractal.js file:

    const fractal = require('@frctl/fractal');
    
    fractal.engine('consolidate', '@frctl/consolidate-engine', {
        engine: 'swig' // The template language to use
    });
    
    fractal.set('components.engine', 'consolidate'); // use the consolidate handler
    fractal.set('components.ext', '.swig'); // look for files with a .swig file extension

    You can see a full list of supported template languages on the Consolidate documentation.

    Template Engine Instances

    You can customise the template engine instance in your fractal.js file if you want to add filters, globals, mixins etc before templates are rendered.

    For example, to extend the above example to use a customised instance of Swig you could do the following:

    const swig    = require('swig');
    const fractal = require('@frctl/fractal');
    
    // Add a custom Swig filter
    swig.setFilter('join', function (input, char) {
      return input.join(char);
    });
    
    fractal.engine('consolidate', '@frctl/consolidate-engine', {
        engine: 'swig',
        instance: swig // Pass in the custom Swig instance
    });
    fractal.set('components.engine', 'consolidate');
    fractal.set('components.ext', '.swig');

    Keywords

    none

    Install

    npm i @frctl/consolidate-engine

    DownloadsWeekly Downloads

    9

    Version

    0.4.0

    License

    MIT

    Last publish

    Collaborators

    • mihkeleidast
    • chapabu
    • tomdavies
    • allmarkedup
    • dkhuntrods