ember-cli-inline-content
Advanced tools
Comparing version 0.3.1 to 0.3.2
@@ -22,2 +22,6 @@ var fs = require('fs'); | ||
contentOptions = ('object' === typeof inlineContentForType) && inlineContentForType; | ||
if (contentOptions && contentOptions.enabled !== undefined && Boolean(contentOptions.enabled) === false) { | ||
return; | ||
} | ||
@@ -24,0 +28,0 @@ if (contentOptions && contentOptions.content) { |
{ | ||
"name": "ember-cli-inline-content", | ||
"version": "0.3.1", | ||
"version": "0.3.2", | ||
"description": "An ember-cli add-on to render inline scripts, styles, or any content directly into your index.html file", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -50,2 +50,3 @@ # ember-cli-inline-content [](https://travis-ci.org/gdub22/ember-cli-inline-content) | ||
- content (String) Literal string content instead of loading a file | ||
- enabled (Boolean) explicitly enable/disable inlining this content | ||
- attrs (Object) Hash of html attributes to add to the generated tags | ||
@@ -150,3 +151,16 @@ - postProcess (Function) Hook to perform any transformations on the loaded file contents | ||
#### Explicitly enable/disable: | ||
Brocfile.js: | ||
```js | ||
var app = new EmberApp({ | ||
inlineContent: { | ||
'analytics' : { | ||
file: './analytics.js', | ||
enabled: process.env.EMBER_ENV === 'production' | ||
} | ||
} | ||
}); | ||
``` | ||
## Why? | ||
@@ -153,0 +167,0 @@ - You want some code to start executing before your whole app downloads |
@@ -129,2 +129,23 @@ var InlineContentRenderer = require('../index.js'); | ||
equal( content, '<script>\n'+file+'console.log(1);'+'\n</script>' ); | ||
}); | ||
}); | ||
test('can explictly enable/disable via option', function() { | ||
var renderer = new InlineContentRenderer(defaultProject); | ||
var app = Object.create(defaultApp); | ||
app.options.inlineContent = { | ||
dummyJs: { | ||
enabled: false, | ||
file: './tests/dummy.js' | ||
} | ||
}; | ||
renderer.included(app); | ||
var content = renderer.contentFor('dummyJs'); | ||
equal( content, undefined ); | ||
app.options.inlineContent.dummyJs.enabled = true; | ||
renderer.included(app); | ||
var content = renderer.contentFor('dummyJs'); | ||
var file = fs.readFileSync(path.join(renderer.project.root, app.options.inlineContent.dummyJs.file), 'utf8'); | ||
equal( content, '<script>\n'+file+'\n</script>' ); | ||
}); |
13844
212
172