Question

Is there a DocPad plugin that could pre-process the js files and use templateData variables and helpers to get configuration values available?

I've tried Hogan, I can get the variables but not call the helpers...

Was it helpful?

Solution

Using ECO plugin for Docpad I could achieve what I was looking for.

I can get both values and call helpers from docpad templateData.

OTHER TIPS

Any templating language will work here are a few examples and their matching templateData variables:

Docpad.coffee

/docpad.coffee

docpadConfig = {
    templateData:
        site:
            url: "http://www.example.com"
}

Eco:

/src/documents/index.html.eco

<p>My site is <%= @site.url %></p>

CoffeeScript:

/src/documents/index.html.coffee

p "My site is " + @site.url

Or within a script file:

/src/documents/scripts/scripts.js.coffee

console.log( @site.url )

/out/scripts/script.js

console.log("http://www.example.com");

Hogan:

/src/documents/index.html.hogan

<p>My site is {{@site.url}}</p>

Jade:

/src/documents/index.html.jade

p My site is #{site.url}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top