mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
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.
61 lines
1.5 KiB
JavaScript
61 lines
1.5 KiB
JavaScript
var _ = require('underscore');
|
|
var selftest = require('../selftest.js');
|
|
var files = require('../files.js');
|
|
import { getUrl } from '../http-helpers.js';
|
|
import { sleepMs } from '../utils.js';
|
|
|
|
var Sandbox = selftest.Sandbox;
|
|
|
|
var MONGO_LISTENING =
|
|
{ stdout: " [initandlisten] waiting for connections on port" };
|
|
|
|
function startRun(sandbox) {
|
|
var run = sandbox.run();
|
|
run.waitSecs(90); // Running from checkout can take a _long_ time
|
|
run.match("myapp");
|
|
run.match("proxy");
|
|
run.tellMongo(MONGO_LISTENING);
|
|
run.match("MongoDB");
|
|
return run;
|
|
};
|
|
|
|
// Test that the static-html package works. It's hard to do this from a unit
|
|
// test.
|
|
selftest.define("static-html - add static content to head and body", () => {
|
|
const s = new Sandbox({ fakeMongo: true });
|
|
|
|
s.createApp('myapp', 'compiler-plugin-static-html');
|
|
s.cd('myapp');
|
|
|
|
const run = startRun(s);
|
|
|
|
// Test that static content is present in HTML response.
|
|
const html = getUrl('http://localhost:3000/');
|
|
selftest.expectTrue(
|
|
html.indexOf(
|
|
`<meta name="viewport" content="width=device-width, initial-scale=1">`
|
|
) !== -1
|
|
);
|
|
|
|
selftest.expectTrue(
|
|
html.indexOf(
|
|
`<div>I have a body, yet no Blaze!</div>`
|
|
) !== -1
|
|
);
|
|
|
|
run.stop();
|
|
});
|
|
|
|
// Test that the static-html package throws the right error
|
|
selftest.define("static-html - throws error", () => {
|
|
const s = new Sandbox({ fakeMongo: true });
|
|
|
|
s.createApp('myapp', 'compiler-plugin-static-html-error');
|
|
s.cd('myapp');
|
|
|
|
const run = startRun(s);
|
|
run.match("Attributes on <head> not supported");
|
|
|
|
run.stop();
|
|
});
|