diff --git a/index.js b/index.js index 8e2b235..888b09a 100644 --- a/index.js +++ b/index.js @@ -58,6 +58,9 @@ module.exports = { setupPreprocessorRegistry(type, registry) { if (type === 'parent') { + let GlimmerComponentPreprocessor = require('./lib/gc-preprocessor-plugin'); + registry.add('js', new GlimmerComponentPreprocessor()); + let TemplateImportPreprocessor = require('./lib/preprocessor-plugin'); registry.add( 'js', diff --git a/lib/gc-preprocessor-plugin.js b/lib/gc-preprocessor-plugin.js new file mode 100644 index 0000000..50533b2 --- /dev/null +++ b/lib/gc-preprocessor-plugin.js @@ -0,0 +1,42 @@ +const stew = require('broccoli-stew'); + +const IMPORT = `import { hbs } from 'ember-template-imports';`; + +module.exports = class GlimmerComponentPreprocessor { + constructor() { + this.name = 'glimmer-component-preprocessor'; + } + + toTree(tree) { + let compiled = stew.map(tree, `**/*.gc`, (contents) => { + const scriptRegex = / + +Hello, I am + + bold + + +2 + 1 = {{plusOne 2}} +! diff --git a/tests/dummy/app/components/gc-template-only.gc b/tests/dummy/app/components/gc-template-only.gc new file mode 100644 index 0000000..7606281 --- /dev/null +++ b/tests/dummy/app/components/gc-template-only.gc @@ -0,0 +1 @@ +Hello, I am bold! diff --git a/tests/dummy/app/components/gc-test.gc b/tests/dummy/app/components/gc-test.gc new file mode 100644 index 0000000..a560f3e --- /dev/null +++ b/tests/dummy/app/components/gc-test.gc @@ -0,0 +1,33 @@ + + +2 + 1 = {{plusOne 2}} + +Counter: {{this.counter}} + + diff --git a/tests/dummy/app/templates/application.hbs b/tests/dummy/app/templates/application.hbs index b4aed8b..9af5ac6 100644 --- a/tests/dummy/app/templates/application.hbs +++ b/tests/dummy/app/templates/application.hbs @@ -1,6 +1,11 @@ -{{page-title "Dummy"}} +{{page-title 'Dummy'}} -