Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blocks in config #387

Closed
jasonmorganson opened this issue Jan 2, 2013 · 4 comments
Closed

Blocks in config #387

jasonmorganson opened this issue Jan 2, 2013 · 4 comments

Comments

@jasonmorganson
Copy link

Provide a way to set block content from the configuration file(s).

It would be good to be able to add styles or scripts into the configuration that are merged into their respective blocks.

@balupton
Copy link
Member

balupton commented Jan 2, 2013

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'
        ])

Btw, would be great if you could catalog this on our stackoverflow forum as that is a better medium for questions. We generally just have the github issue tracker for bug reports and dev tasks related to milestones etc :) Let me know if there is anything I can do to make that more clear. Cheers! Also let me know if the above snippets work :)

@jasonmorganson
Copy link
Author

That did the trick. I will add it to stackoverflow. Thanks!

@sergeylukin
Copy link

Is it @Getblock() or @docpad.getBlock() ?

Also is it possible to add strings to block on per-page basis? When I call @docpad.getBlock('scripts').add() on one page (via render event), it's added to all pages..

@sergeylukin
Copy link

Sorry, @balupton actually answered this already: #328 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants