Skip to content

Commit

Permalink
changing conf option names to support sending in pre-load steal optio…
Browse files Browse the repository at this point in the history
…ns to the template
  • Loading branch information
jaredstehler-cengage committed May 6, 2013
1 parent af97fef commit 5506dc5
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Gruntfile.js
Expand Up @@ -52,7 +52,7 @@ module.exports = function(grunt) {
host: 'http://127.0.0.1:<%= connect.test.options.port %>/',
template : require('./'),
templateOptions: {
stealOptions : {
steal : {
map: {
'test': '../../test'
}
Expand Down
20 changes: 16 additions & 4 deletions README.md
Expand Up @@ -9,17 +9,26 @@ npm install grunt-template-jasmine-steal --save-dev

## Template Options

### templateOptions.stealOptions.stealUrl
### templateOptions.steal.url
Type: `String`
Default: path to steal.js (defaults to internal version, probably not desired)

The steal script to use.

### templateOptions.stealOptions.map
### templateOptions.steal.map
Type: `Object`

This object is `JSON.stringify()`-ed into the template and passed into `steal.map()`

### templateOptions.steal.executed
Type: `Object`

This object is `JSON.stringify()`-ed into the template and passed into `steal.executed()`

### templateOptions.steal.options
Type: `Object`

This object is `JSON.stringify()`-ed into the template and set as the default steal options object in the page, before steal is loaded.

## Sample usage

Expand All @@ -44,10 +53,13 @@ grunt.initConfig({
host: 'http://127.0.0.1:<%= connect.test.options.port %>/',
template: require('grunt-template-jasmine-steal'),
templateOptions: {
stealOptions: {
stealUrl: 'src/steal/steal.js',
steal: {
url: 'src/steal/steal.js',
map: {
'.grunt': '../.grunt'
},
options: {
logLevel: 3
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "grunt-template-jasmine-steal",
"version": "0.3.0",
"version": "0.3.1",
"description": "StealJS template for grunt-contrib-jasmine",
"main": "src/template-jasmine-steal.js",
"scripts": {
Expand Down
8 changes: 2 additions & 6 deletions src/template-jasmine-steal.js
Expand Up @@ -9,7 +9,7 @@ var template = __dirname + '/templates/jasmine-steal.html',
exports.process = function(grunt, task, context) {
context.options.stealOptions = context.options.stealOptions || {};

var stealUrl = context.options.stealOptions.stealUrl;
var stealUrl = context.options.steal.url;

// find the latest version if none given
if (!stealUrl) {
Expand All @@ -18,7 +18,7 @@ exports.process = function(grunt, task, context) {

var stealRoot = stealUrl.substring(0, stealUrl.indexOf('steal/steal.js'));

context.options.stealOptions.stealUrl = stealUrl;
context.options.steal.url = stealUrl;

context.fn = {
pathify: function(s) {
Expand All @@ -35,10 +35,6 @@ exports.process = function(grunt, task, context) {
}
};

context.options.stealOptions.config = grunt.util._.extend({

}, context.options.stealOptions.config);

// put steal into place
task.copyTempFile(steal['3.2.3'] + '/steal.js','steal/steal.js');
task.copyTempFile(steal['3.2.3'] + '/dev/dev.js','steal/dev/dev.js');
Expand Down
17 changes: 12 additions & 5 deletions src/templates/jasmine-steal.html
Expand Up @@ -4,16 +4,23 @@
<meta charset="utf-8">
<title>Jasmine Spec Runner</title>

<script src="<%= options.stealOptions.stealUrl %>"></script>
<% if (options.stealOptions.map) { %>
<% if(options.steal.options) { %>
<script>
steal.map(<%= JSON.stringify(options.stealOptions.map) %>);
steal = <%= JSON.stringify(options.steal.options) %>
</script>
<% } %>

<% if(options.stealOptions.executed) { %>
<script src="<%= options.steal.url %>"></script>

<% if (options.steal.map) { %>
<script>
steal.map(<%= JSON.stringify(options.steal.map) %>);
</script>
<% } %>

<% if(options.steal.executed) { %>
<script>
<% options.stealOptions.executed.forEach(function(script) { %>
<% options.steal.executed.forEach(function(script) { %>
steal.executed("<%= script %>");
<% }) %>
</script>
Expand Down

0 comments on commit 5506dc5

Please sign in to comment.