Skip to content

Commit 7574272

Browse files
dmunerassamselikoff
authored andcommitted
enhancement: Add config options to indicate the file extensions that ember-code-snippet needs to use (#411)
Since this PR: https://github.com/ef4/ember-code-snippet/pull/59/files it is possilbe to indicate the extensions to look for snippets, this PR just add the option to use the functionlity
1 parent 47df47f commit 7574272

File tree

4 files changed

+58
-1
lines changed

4 files changed

+58
-1
lines changed

index.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,27 @@ module.exports = {
103103
}, includer.options.snippetRegexes);
104104
includer.options.includehighlightJS = false;
105105
includer.options.includeHighlightStyle = false;
106-
includer.options.snippetExtensions = ['js', 'css', 'scss', 'hbs', 'md', 'text', 'json', 'handlebars', 'htmlbars', 'html', 'diff'];
106+
107+
let snippetExtensions = includer.options.snippetExtensions;
108+
109+
if (!Array.isArray(includer.options.snippetExtensions)) {
110+
snippetExtensions = [
111+
'ts',
112+
'js',
113+
'css',
114+
'scss',
115+
'hbs',
116+
'md',
117+
'text',
118+
'json',
119+
'handlebars',
120+
'htmlbars',
121+
'html',
122+
'diff'
123+
];
124+
}
125+
126+
includer.options.snippetExtensions = snippetExtensions;
107127

108128
// This must come after we add our own options above, or else other addons won't see them.
109129
this._super.included.apply(this, arguments);
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Build options
2+
3+
To override the default configuration of the addon, use the following options in your `ember-cli-build.js`.
4+
5+
## snippetExtensions
6+
7+
Override the default file extensions where [ember-code-snippet](https://github.com/ef4/ember-code-snippet) looks for snippets.
8+
9+
### Default:
10+
11+
`['js','ts','coffee','html','hbs','md','css','sass','scss','less','emblem','yaml']`
12+
13+
### How to use it
14+
15+
{{#docs-snippet name='build-options-snippet-extensions.js' title='app/ember-cli-build.js'}}
16+
/* global require, module */
17+
const EmberAddon = require('ember-cli/lib/broccoli/ember-addon');
18+
19+
module.exports = function(defaults) {
20+
let app = new EmberAddon(defaults, {
21+
// More config options of your app here
22+
23+
snippetExtensions: ['js','ts','coffee','html','hbs','md','css','sass','scss','less','emblem','yaml'],
24+
25+
// More config options of your app here
26+
});
27+
28+
return app.toTree();
29+
};
30+
{{/docs-snippet}}
31+
32+
33+
34+
35+

tests/dummy/app/pods/docs/template.hbs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
{{nav.item 'Usage' 'docs.usage'}}
77
{{nav.item 'Quickstart' 'docs.quickstart'}}
88
{{nav.item 'Patterns' 'docs.patterns'}}
9+
{{nav.item 'Build options' 'docs.build-options'}}
910
{{nav.item 'Deploying' 'docs.deploying'}}
1011

1112
{{nav.section 'Components'}}

tests/dummy/app/router.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Router.map(function() {
1212
this.route('usage');
1313
this.route('quickstart');
1414
this.route('patterns');
15+
this.route('build-options');
1516
this.route('deploying');
1617

1718
this.route('components', function() {

0 commit comments

Comments
 (0)