Files
meteor/packages/templating-tools/throw-compile-error.js
Sashko Stubailo ec33215a7f Static HTML package and templating refactor
1. Make a package called `static-html` that just compiles `<head>` and `<body>` tags inside `.html` files. Much like templating but without the templates.
2. Refactor `templating` to avoid duplicating code.

Split out code that would be shared between `templating` and `static-html` into a new `templating-tools` package. These tools could also be used to simplify implementation of other build plugins, like `simple:markdown-templating`.

This also has the added benefit of moving as much code as humanly possible out of the `templating` package, so that it can be reused in other packages.

1. `templating-tools` package and its README
2. `static-html` package and its README
3. `caching-html-compiler` is not new code; it is just code factored out of the batch plugin version of `templating`, but the README and some comments are new.

1. `tools/tests/static-html.js` tests static html and error handling
2. `templating-tools/html-scanner-tests.js` tests `scanHtmlForTags` and `compileTagsWithSpacebars` together.

All unit tests pass on this branch.
2015-07-31 10:40:23 -07:00

12 lines
424 B
JavaScript

TemplatingTools.throwCompileError =
function throwCompileError(tag, message, overrideIndex) {
const finalIndex = (typeof overrideIndex === 'number' ?
overrideIndex : tag.tagStartIndex);
const err = new TemplatingTools.CompileError();
err.message = message || "bad formatting in template file";
err.file = tag.sourceName;
err.line = tag.fileContents.substring(0, finalIndex).split('\n').length;
throw err;
}