Skip to content
This repository has been archived by the owner on Dec 8, 2024. It is now read-only.

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonmit committed May 13, 2016
1 parent 4074581 commit 41c8e30
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,32 @@ var HTMLBarsInlinePrecompile = require('babel-plugin-htmlbars-inline-precompile'
var pluginConfiguredWithCompiler = HTMLBarsInlinePrecompile(HTMLBarsCompiler.precompile);

require('babel').transform("code", {
plugins: [ pluginConfiguredWithCompiler ]
plugins: [ pluginConfiguredWithCompiler]
});
```

### Passing options to the precompiler

As of 0.0.6, there is now the ability to pass options to the HTMLBars precompiler.

This enables passing `moduleName`, which can be used to retrieve from within the compiled template where it originated from.

``` js
var HTMLBarsCompiler = require('./bower_components/ember/ember-template-compiler');
var HTMLBarsInlinePrecompile = require('babel-plugin-htmlbars-inline-precompile');

var pluginConfiguredWithCompiler = HTMLBarsInlinePrecompile(HTMLBarsCompiler.precompile, {
precompileOptions: function(opts) {
// example of moduleName generation
var sourceRootRegEx = new RegExp("^" + opts.sourceRoot + "/?");

return {
moduleName: opts.filenameRelative.replace(sourceRootRegEx, "")
};
}
});

require('babel').transform("code", {
plugins: [ pluginConfiguredWithCompiler]
});
```

0 comments on commit 41c8e30

Please sign in to comment.