Skip to content

Commit 19bdace

Browse files
author
Chris Garrett
authored
[FEAT] Extract the Handlebars parser (#1713)
Extracts the parser to `@handlebars/parser`, where it can be shared between different implementations. This means that e.g. Glimmer/Ember will be able to iterate on new features without forcing Handlebars to adopt them immediately, and vice versa. All implementors will be able to absorb changes as it makes sense for them.
1 parent 071003b commit 19bdace

34 files changed

+58
-2268
lines changed

.eslintignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ node_modules
1212
.nyc_output
1313

1414
# Generated files
15-
lib/handlebars/compiler/parser.js
1615
/coverage/
1716
/dist/
1817
/integration-testing/*/dist/

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ node_modules
1313
.nyc_output
1414

1515
# Generated files
16-
lib/handlebars/compiler/parser.js
1716
/coverage/
1817
/dist/
1918
/integration-testing/*/dist/
20-
/spec/tmp/*
19+
/spec/tmp/*

.prettierignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ node_modules
1212
.nyc_output
1313

1414
# Generated files
15-
lib/handlebars/compiler/parser.js
1615
/coverage/
1716
/dist/
1817
/integration-testing/*/dist/

Gruntfile.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,7 @@ module.exports = function(grunt) {
33
grunt.initConfig({
44
pkg: grunt.file.readJSON('package.json'),
55

6-
clean: [
7-
'tmp',
8-
'dist',
9-
'lib/handlebars/compiler/parser.js',
10-
'integration-testing/**/node_modules'
11-
],
6+
clean: ['tmp', 'dist', 'integration-testing/**/node_modules'],
127

138
copy: {
149
dist: {
@@ -198,7 +193,7 @@ module.exports = function(grunt) {
198193
this.registerTask(
199194
'build',
200195
'Builds a distributable version of the current project',
201-
['parser', 'node', 'globals']
196+
['node', 'globals']
202197
);
203198

204199
this.registerTask('node', ['babel:cjs']);

lib/handlebars.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1+
import {
2+
parser as Parser,
3+
parse,
4+
parseWithoutProcessing,
5+
Visitor
6+
} from '@handlebars/parser';
7+
18
import runtime from './handlebars.runtime';
29

310
// Compiler imports
411
import AST from './handlebars/compiler/ast';
5-
import {
6-
parser as Parser,
7-
parse,
8-
parseWithoutProcessing
9-
} from './handlebars/compiler/base';
1012
import { Compiler, compile, precompile } from './handlebars/compiler/compiler';
1113
import JavaScriptCompiler from './handlebars/compiler/javascript-compiler';
12-
import Visitor from './handlebars/compiler/visitor';
1314

1415
import noConflict from './handlebars/no-conflict';
1516

lib/handlebars.runtime.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
import { Exception } from '@handlebars/parser';
12
import * as base from './handlebars/base';
23

34
// Each of these augment the Handlebars object. No need to setup here.
45
// (This is done to easily share code between commonjs and browse envs)
56
import SafeString from './handlebars/safe-string';
6-
import Exception from './handlebars/exception';
77
import * as Utils from './handlebars/utils';
88
import * as runtime from './handlebars/runtime';
99

lib/handlebars/base.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import { Exception } from '@handlebars/parser';
12
import { createFrame, extend, toString } from './utils';
2-
import Exception from './exception';
33
import { registerDefaultHelpers } from './helpers';
44
import { registerDefaultDecorators } from './decorators';
55
import logger from './logger';

lib/handlebars/compiler/base.js

Lines changed: 0 additions & 34 deletions
This file was deleted.

lib/handlebars/compiler/compiler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-disable new-cap */
22

3-
import Exception from '../exception';
3+
import { Exception } from '@handlebars/parser';
44
import { isArray, indexOf, extend } from '../utils';
55
import AST from './ast';
66

lib/handlebars/compiler/helpers.js

Lines changed: 0 additions & 219 deletions
This file was deleted.

0 commit comments

Comments
 (0)