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

Commit

Permalink
Rename createTemplate to precompileTemplate to match spec defined in rfc
Browse files Browse the repository at this point in the history
  • Loading branch information
chiragpat committed Jan 6, 2021
1 parent 63f257c commit ddc2e96
Show file tree
Hide file tree
Showing 26 changed files with 95 additions and 95 deletions.
4 changes: 2 additions & 2 deletions packages/@glimmer/blueprint/files/src/App.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Component from '@glimmer/component';
import { setComponentTemplate, createTemplate } from '@glimmer/core';
import { setComponentTemplate, precompileTemplate } from '@glimmer/core';

import logo from './logo.svg';
import './App.css';
Expand All @@ -9,7 +9,7 @@ export default class App extends Component {
}

setComponentTemplate(
createTemplate(`
precompileTemplate(`
<div id="intro">
<img src={{this.logo}}/>
Expand Down
6 changes: 3 additions & 3 deletions packages/@glimmer/component/test/interactive/args-test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';

import { setComponentTemplate, createTemplate } from '@glimmer/core';
import { setComponentTemplate, precompileTemplate } from '@glimmer/core';
import { test, render, settled } from '@glimmer/core/test/utils';

QUnit.module('[@glimmer/component] Component Arguments', () => {
Expand All @@ -27,14 +27,14 @@ QUnit.module('[@glimmer/component] Component Arguments', () => {
}

setComponentTemplate(
createTemplate(
precompileTemplate(
{ ChildComponent },
'<ChildComponent @firstName={{this.firstName}} @status={{this.status}} />'
),
ParentComponent
);

setComponentTemplate(createTemplate('{{this.name}} {{@status}}'), ChildComponent);
setComponentTemplate(precompileTemplate('{{this.name}} {{@status}}'), ChildComponent);

assert.equal(await render(ParentComponent), 'Tom Dale is dope');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';

import { test, render, settled } from '@glimmer/core/test/utils';
import { setComponentTemplate, createTemplate } from '@glimmer/core';
import { setComponentTemplate, precompileTemplate } from '@glimmer/core';

QUnit.module('[@glimmer/component] Lifecycle Hooks', () => {
test('Lifecycle hook ordering', async function (assert) {
Expand Down Expand Up @@ -37,7 +37,7 @@ QUnit.module('[@glimmer/component] Lifecycle Hooks', () => {
class Component5 extends HookLoggerComponent {}

setComponentTemplate(
createTemplate(
precompileTemplate(
{ Component2, Component3 },
`
{{#if this.showChildren}}
Expand All @@ -50,7 +50,7 @@ QUnit.module('[@glimmer/component] Lifecycle Hooks', () => {
);

setComponentTemplate(
createTemplate(
precompileTemplate(
{ Component4, Component5 },
`
{{@firstName}}
Expand All @@ -61,7 +61,7 @@ QUnit.module('[@glimmer/component] Lifecycle Hooks', () => {
Component2
);

const emptyTemplate = createTemplate('');
const emptyTemplate = precompileTemplate('');

setComponentTemplate(emptyTemplate, Component3);
setComponentTemplate(emptyTemplate, Component4);
Expand Down
2 changes: 1 addition & 1 deletion packages/@glimmer/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ export {

export { getOwner, setOwner } from '@glimmer/owner';

export { createTemplate, setComponentTemplate } from './src/template';
export { precompileTemplate, setComponentTemplate } from './src/template';
6 changes: 3 additions & 3 deletions packages/@glimmer/core/src/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import { SerializedTemplateWithLazyBlock, Dict } from '@glimmer/interfaces';
import { templateFactory } from '@glimmer/opcode-compiler';

// This is provided by the `babel-plugin-strict-template-precompile` plugin
export let createTemplate: (
export let precompileTemplate: (
scopeOrTemplate: Dict<unknown> | string,
template?: string
) => SerializedTemplateWithLazyBlock;

if (DEBUG) {
createTemplate = (): SerializedTemplateWithLazyBlock => {
precompileTemplate = (): SerializedTemplateWithLazyBlock => {
throw new Error(
'createTemplate() is meant to be preprocessed with a babel plugin, @glimmer/babel-plugin-strict-template-precompile. If you are seeing this error message, it means that you do not have this babel plugin installed, or it is not enabled correctly'
'precompileTemplate() is meant to be preprocessed with a babel plugin, @glimmer/babel-plugin-strict-template-precompile. If you are seeing this error message, it means that you do not have this babel plugin installed, or it is not enabled correctly'
);
};
}
Expand Down
12 changes: 6 additions & 6 deletions packages/@glimmer/core/test/interactive/fn-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Component from '@glimmer/component';
import { fn } from '@glimmer/helper';
import { on, action } from '@glimmer/modifier';

import { setComponentTemplate, createTemplate, templateOnlyComponent } from '@glimmer/core';
import { setComponentTemplate, precompileTemplate, templateOnlyComponent } from '@glimmer/core';

QUnit.module('[@glimmer/core] interactive - {{fn}}', () => {
test('can curry arguments via fn', async function (assert) {
Expand All @@ -29,7 +29,7 @@ QUnit.module('[@glimmer/core] interactive - {{fn}}', () => {
}

setComponentTemplate(
createTemplate(
precompileTemplate(
{ on, fn },
'<button {{on "click" (fn this.userDidClick "hello" @name)}}>Hello World</button>'
),
Expand Down Expand Up @@ -82,20 +82,20 @@ QUnit.module('[@glimmer/core] interactive - {{fn}}', () => {
}

const Grandchild = setComponentTemplate(
createTemplate({ on, fn }, '<button {{on "click" (fn @userDidClick 5 6)}}></button>'),
precompileTemplate({ on, fn }, '<button {{on "click" (fn @userDidClick 5 6)}}></button>'),
templateOnlyComponent()
);

const Child = setComponentTemplate(
createTemplate(
precompileTemplate(
{ Grandchild, fn },
'<div><Grandchild @userDidClick={{fn @userDidClick 3 4}} /></div>'
),
templateOnlyComponent()
);

setComponentTemplate(
createTemplate(
precompileTemplate(
{ Child, fn },
'<div><Child @userDidClick={{fn this.userDidClick 1 2}} /></div>'
),
Expand All @@ -116,7 +116,7 @@ QUnit.module('[@glimmer/core] interactive - {{fn}}', () => {
class Parent extends Component {}

setComponentTemplate(
createTemplate({ on, fn }, '<button {{on "click" (fn this.doesntExist)}}></button>'),
precompileTemplate({ on, fn }, '<button {{on "click" (fn this.doesntExist)}}></button>'),
Parent
);

Expand Down
4 changes: 2 additions & 2 deletions packages/@glimmer/core/test/interactive/modifier-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { test, render, settled, tracked } from '../utils';
import { click } from '../utils/dom';
import { on, action } from '@glimmer/modifier';
import Component from '@glimmer/component';
import { setComponentTemplate, createTemplate } from '@glimmer/core';
import { setComponentTemplate, precompileTemplate } from '@glimmer/core';

QUnit.module('Modifier Tests', () => {
test('Supports the on modifier', async (assert) => {
Expand All @@ -16,7 +16,7 @@ QUnit.module('Modifier Tests', () => {
}

setComponentTemplate(
createTemplate(
precompileTemplate(
{ on },
`<button {{on "click" this.incrementCounter}}>Count: {{@count}}</button>`
),
Expand Down
12 changes: 6 additions & 6 deletions packages/@glimmer/core/test/interactive/render-test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createTemplate } from '@glimmer/core';
import { precompileTemplate } from '@glimmer/core';

import { test, render } from '../utils';

Expand All @@ -11,8 +11,8 @@ QUnit.module(`[@glimmer/core] interactive rendering tests`, () => {
const firstContainerElement = document.createElement('div');
const secondContainerElement = document.createElement('div');

await render(createTemplate(`<h1>Hello Glimmer!</h1>`), firstContainerElement);
await render(createTemplate(`<h1>Hello Robbie!</h1>`), secondContainerElement);
await render(precompileTemplate(`<h1>Hello Glimmer!</h1>`), firstContainerElement);
await render(precompileTemplate(`<h1>Hello Robbie!</h1>`), secondContainerElement);

assert.equal(firstContainerElement.innerHTML, '<h1>Hello Glimmer!</h1>');
assert.equal(secondContainerElement.innerHTML, '<h1>Hello Robbie!</h1>');
Expand All @@ -30,7 +30,7 @@ QUnit.module(`[@glimmer/core] interactive rendering tests`, () => {
containerElement.appendChild(previousSibling);
containerElement.appendChild(document.createTextNode('bar'));

await render(createTemplate(`<h1>Hello Glimmer!</h1>`), containerElement);
await render(precompileTemplate(`<h1>Hello Glimmer!</h1>`), containerElement);

assert.equal(containerElement.innerHTML, '<p>foo</p>bar<h1>Hello Glimmer!</h1>');
});
Expand All @@ -40,7 +40,7 @@ QUnit.module(`[@glimmer/core] interactive rendering tests`, () => {
containerElement.innerHTML =
'<!--%+b:0%--><!--%+b:1%--><h1>Hello World</h1><!--%-b:1%--><!--%-b:0%-->';

await render(createTemplate(`<h1>Hello World</h1>`), {
await render(precompileTemplate(`<h1>Hello World</h1>`), {
element: containerElement,
rehydrate: true,
});
Expand All @@ -53,7 +53,7 @@ QUnit.module(`[@glimmer/core] interactive rendering tests`, () => {
containerElement.innerHTML =
'<!--%+b:0%--><!--%+b:1%--><div id="test"><!--%+b:2%--><h1>Hello <!--%+b:3%-->World<!--%-b:3%--></h1><!--%-b:2%--></div><!--%-b:1%--><!--%-b:0%-->';

await render(createTemplate(`<h1>Hello {{@name}}</h1>`), {
await render(precompileTemplate(`<h1>Hello {{@name}}</h1>`), {
element: containerElement.querySelector('#test')!,
rehydrate: true,
args: {
Expand Down
16 changes: 8 additions & 8 deletions packages/@glimmer/core/test/non-interactive/each-test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Component from '@glimmer/component';

import { test, render } from '../utils';
import { setComponentTemplate, createTemplate } from '@glimmer/core';
import { setComponentTemplate, precompileTemplate } from '@glimmer/core';

function freeze<T>(array: T[]): ReadonlyArray<Readonly<T>> {
return Object.freeze(array.slice().map<T>(Object.freeze));
Expand All @@ -23,7 +23,7 @@ QUnit.module('[@glimmer/core] each helper', () => {
const Component = class extends HelloWorld {};

setComponentTemplate(
createTemplate(
precompileTemplate(
`<ul>{{#each this.strings key="@unknown" as |item|}}<li>{{item}}</li>{{/each}}</ul>`
),
Component
Expand All @@ -38,7 +38,7 @@ QUnit.module('[@glimmer/core] each helper', () => {
const Component = class extends HelloWorld {};

setComponentTemplate(
createTemplate(
precompileTemplate(
`<ul>{{#each this.numbers key="@index" as |item|}}<li>{{item}}</li>{{/each}}</ul>`
),
Component
Expand All @@ -53,7 +53,7 @@ QUnit.module('[@glimmer/core] each helper', () => {
const Component = class extends HelloWorld {};

setComponentTemplate(
createTemplate(
precompileTemplate(
`<ul>{{#each this.frozenNumbers key="@index" as |item|}}<li>{{item}}</li>{{/each}}</ul>`
),
Component
Expand All @@ -68,7 +68,7 @@ QUnit.module('[@glimmer/core] each helper', () => {
const Component = class extends HelloWorld {};

setComponentTemplate(
createTemplate(
precompileTemplate(
`<ul>{{#each this.strings key="@index" as |item|}}<li>{{item}}</li>{{/each}}</ul>`
),
Component
Expand All @@ -83,7 +83,7 @@ QUnit.module('[@glimmer/core] each helper', () => {
const Component = class extends HelloWorld {};

setComponentTemplate(
createTemplate(
precompileTemplate(
`<ul>{{#each this.frozenStrings key="@index" as |item|}}<li>{{item}}</li>{{/each}}</ul>`
),
Component
Expand All @@ -98,7 +98,7 @@ QUnit.module('[@glimmer/core] each helper', () => {
const Component = class extends HelloWorld {};

setComponentTemplate(
createTemplate(
precompileTemplate(
`<ul>{{#each this.objects key="@index" as |item|}}<li>{{item.name}}</li>{{/each}}</ul>`
),
Component
Expand All @@ -113,7 +113,7 @@ QUnit.module('[@glimmer/core] each helper', () => {
const Component = class extends HelloWorld {};

setComponentTemplate(
createTemplate(
precompileTemplate(
`<ul>{{#each this.frozenObjects key="@index" as |item|}}<li>{{item.name}}</li>{{/each}}</ul>`
),
Component
Expand Down
Loading

0 comments on commit ddc2e96

Please sign in to comment.