Jason Morganson
Jason Morganson

Reputation: 51

Add to blocks from the DocPad configuration file

How to add to blocks from the configuration file?

Eg: Set a list of scripts/styles to include in the block by doing something like:

    @getBlock('scripts').add([
        '/vendor/jquery.js'
        '/vendor/jquery-ui.js'
    ])

In the configuration file.

Upvotes: 2

Views: 453

Answers (1)

Jason Morganson
Jason Morganson

Reputation: 51

As per Issue #387 on GitHub, answered by balupton:

There are two ways we generally can do this.

Via TemplateData

templateData:
    site:
        scripts: [
            '/vendor/jquery.js'
            '/vendor/jquery-ui.js'
            ]

Then inside your layout:

<%- @getBlock('scripts').add(@site.scripts).toHTML()

Via Populate Collections Event

events:
    populateCollections: ->
        @getBlock('scripts').add([
            '/vendor/jquery.js'
            '/vendor/jquery-ui.js'
        ])

Upvotes: 3

Related Questions