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

Support compilation of pre-processors (coffee-script, jade, sass, ...) #149

Closed
balupton opened this issue Apr 23, 2012 · 5 comments
Closed

Comments

@balupton
Copy link

This is more a todo for a custom task, than something for the core.

For the person who wants to get started, we could use the DocPad rendering engine to support all the renderers docpad already supports.

To compile coffeescript it would be something like this (note... I have not yet experimented with the grunt API, so only guessing how it works at this point...)

npm install docpad docpad-plugin-coffee
# Prepare
docpad = require('docpad')
docpadInstance = null

# Grunt setup (guessing here)
grunt.on 'setup', (next) ->
    docpad.createInstance {}, (err) ->
        return next(err)

# Listen to tasks
grunt.on 'task', (next,filePath,content) ->
    details =
        filename: filePath
        content: content
    docpad.action 'render', details, (err,document) ->
        return next(err)  if err
        result = document.get('contentRendered')
        return next(null,result)
@raDiesle
Copy link

Do you know about grunt-contrib ?
Would be nice to add more tasks !

@JamesMGreene
Copy link
Contributor

There is a SASS task in the process of being added to grunt-contrib by @tkellen.

@balupton
Copy link
Author

balupton commented Jul 8, 2012

Cool, although the idea of using DocPad is that you automatically support everything that DocPad supports, so you have one grunt task that utilises the docpad rendering engine, so supporting a new pre-processor is as simple as installing the associated Plugin for it.

The javascript code to do this is with the latest versin of DocPad is:

require('docpad').createInstance(function(err,docpadInstance){
    docpadInstance.action('render', {path:someFilePath}, function(err,result){
        console.log(result);
    });
});

And then for example to instantly add support for sass, stylus, haml, jade, coffeescript, coffeekup, etc it would just be a matter of installing the docpad plugins, so:

npm install docpad-plugin-stylus
npm install docpad-plugin-sass
npm install docpad-plugin-haml
npm install docpad-plugin-jade
npm install docpad-plugin-coffee

This way has several advantages:

  • all the maintenance of pre-processor rendering is maintained by the very active docpad community (we've been around for over a year now), and accessible via installing a docpad plugin over NPM. Rather than having to write and maintain a new grunt task for every single pre-processor, you just write one, that leverages all the work the docpad community has already done.
  • could also gain support for partials, layouts, and meta data parsing with further customisation (would require parsing all the files beforehand)

They're pretty big pluses in my opinion. The grunt API isn't that intuitive to me, so I'd be happy to work with anyone who wants to write the task. Just shoot me up on Skype (username balupton) or comment here.

@tkellen
Copy link
Member

tkellen commented Jul 8, 2012

Heya Benjamin! Would you mind opening an issue for this over at http://github.com/gruntjs/grunt-contrib? Depending on how well this is implemented (I don't know anything about docpad yet), this might be able to eliminate/enhance quite a few of our tasks.

Both @ctalkington and I can help you with any questions you have about implementing tasks. Also, if you work well by example, there are quite a few well-written ones to draw from on contrib.

@shama
Copy link
Member

shama commented Jul 10, 2012

fyi, I've just converted https://github.com/shama/grunt-docs to use DocPad. I'd love to get any feedback on it. Thanks!

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

6 participants