Reputation: 2197
This is my Gruntfile:
'use strict';
module.exports = function (grunt) {
require('load-grunt-tasks')(grunt);
grunt.initConfig({
site: grunt.file.readYAML('_config.yml'),
coffee: {
dist: {
files: [{
expand: true,
cwd: "<%= site.src %>/assets/scripts",
src: "{,*/}*.coffee",
dest: "<%= site.tmp %>/assets/scripts",
ext: ".js"
}]
}
}
});
grunt.registerTask('default', ['coffee']);
}
I want to have app/assets/scripts/globals.coffee
look something like this:
jQuery ($) ->
window.Site = "<%= site %>"
How can I interpolate the site
variable in CoffeeScript files?
I tried using plugins like grunt-contrib-handlebars and grunt-contrib-jst, but those generate JST files which I think isn't what I want.
Upvotes: 0
Views: 313
Reputation: 46569
Looks to me like a combination of Yaml and Assemble's Data would do what you need.
http://assemble.io/docs/Data.html
FTA:
YAML example
Here is the same in YAML format:
my-template.yml
title: Assemble author: Brian Woodward
And this template:
my-template.hbs
<h1>{{ title }}</h1>
You can adapt that to insert a script tag at the top of the page that sets window.Site = {{site.name}}
.
Upvotes: 1