Skip to content

Commit

Permalink
Merge pull request #13719 from chadhietala/cleanup-compile-helpers
Browse files Browse the repository at this point in the history
[CLEANUP] Compile/precompile should use same code path
  • Loading branch information
rwjblue authored Jun 21, 2016
2 parents 0d8a7e0 + ad29f5b commit 2335a91
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 34 deletions.
16 changes: 16 additions & 0 deletions packages/ember-glimmer-template-compiler/tests/utils/helpers.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
import {
template,
precompile as precompiler,
compile as compiler,
defaultCompileOptions
} from 'ember-glimmer-template-compiler';
import assign from 'ember-metal/assign';

export * from 'ember-glimmer-template-compiler';
export { removePlugin } from 'ember-glimmer-template-compiler/system/compile-options';
export const packageName = 'glimmer';
export const engineName = 'Glimmer';

export function precompile(string) {
return template(precompiler(string));
}

export function compile(string, options) {
return compiler(string, assign({}, defaultCompileOptions(), options));
}
18 changes: 4 additions & 14 deletions packages/ember-glimmer/tests/utils/helpers.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import assign from 'ember-metal/assign';
import {
compile as compiler,
precompile as precompiler,
defaultCompileOptions,
template
} from 'ember-glimmer-template-compiler';
import { setupApplicationRegistry, setupEngineRegistry } from 'ember-glimmer/setup-registry';
import { default as _buildOwner } from 'container/tests/test-helpers/build-owner';

export {
compile,
precompile
} from 'ember-glimmer-template-compiler/tests/utils/helpers';
export { default as Helper, helper } from 'ember-glimmer/helper';
export { INVOKE } from 'ember-glimmer/helpers/action';
export { default as Component } from 'ember-glimmer/component';
Expand All @@ -29,10 +26,3 @@ export function buildOwner(options) {
return owner;
}

export function precompile(string) {
return template(precompiler(string));
}

export function compile(string, options) {
return compiler(string, assign({}, defaultCompileOptions(), options));
}
12 changes: 11 additions & 1 deletion packages/ember-htmlbars-template-compiler/tests/utils/helpers.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { compile as compiler, defaultCompileOptions } from 'ember-htmlbars-template-compiler';
import {
compile as compiler,
precompile as precompiler,
defaultCompileOptions
} from 'ember-htmlbars-template-compiler';
import assign from 'ember-metal/assign';

export * from 'ember-htmlbars-template-compiler';
Expand All @@ -7,5 +11,11 @@ export { removePlugin } from 'ember-htmlbars-template-compiler/system/compile-op
export function compile(string, options) {
return compiler(string, assign({}, defaultCompileOptions(), options));
}

export function precompile(string, options) {
return precompiler(string, assign({}, defaultCompileOptions(), options));
}

export const packageName = 'htmlbars';
export const engineName = 'HTMLBars';

18 changes: 4 additions & 14 deletions packages/ember-htmlbars/tests/utils/helpers.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import assign from 'ember-metal/assign';
import {
compile as compiler,
precompile as precompiler
} from 'ember-htmlbars-template-compiler';
import { defaultCompileOptions } from 'ember-htmlbars-template-compiler';
import { setupApplicationRegistry, setupEngineRegistry } from 'ember-htmlbars/setup-registry';
import { default as _buildOwner } from 'container/tests/test-helpers/build-owner';
import Environment from './environment';

export {
compile,
precompile
} from 'ember-htmlbars-template-compiler/tests/utils/helpers';
export { template } from 'ember-htmlbars-template-compiler';
export { default as Helper, helper } from 'ember-htmlbars/helper';
export { INVOKE } from 'ember-htmlbars/keywords/closure-action';
Expand All @@ -27,11 +25,3 @@ export function buildOwner(options) {
owner.inject('service:-htmlbars-environment', 'dom', 'service:-dom-helper');
return owner;
}

export function compile(string, options) {
return compiler(string, assign({}, defaultCompileOptions(), options));
}

export function precompile(string, options) {
return precompiler(string, assign({}, defaultCompileOptions(), options));
}
7 changes: 2 additions & 5 deletions packages/ember-template-compiler/tests/utils/helpers.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import assign from 'ember-metal/assign';
import { defaultCompileOptions } from 'ember-template-compiler';
import isEnabled from 'ember-metal/features';
import require from 'require';

export function compile(string, options) {
options = assign({}, defaultCompileOptions(), options);
let compiler;
if (isEnabled('ember-glimmer')) {
compiler = require('ember-glimmer-template-compiler').compile;
compiler = require('ember-glimmer-template-compiler/tests/utils/helpers').compile;
} else {
compiler = require('ember-htmlbars-template-compiler').compile;
compiler = require('ember-htmlbars-template-compiler/tests/utils/helpers').compile;
}

return compiler(string, options);
Expand Down

0 comments on commit 2335a91

Please sign in to comment.