Files
meteor/packages/templating/package.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

49 lines
1.6 KiB
JavaScript

Package.describe({
summary: "Allows templates to be defined in .html files",
version: '1.1.2-plugins.1'
});
// Today, this package is closely intertwined with Handlebars, meaning
// that other templating systems will need to duplicate this logic. In
// the future, perhaps we should have the concept of a template system
// registry and a default templating system, ideally per-package.
Package.registerBuildPlugin({
name: "compileTemplatesBatch",
// minifiers is a weak dependency of spacebars-compiler; adding it here
// ensures that the output is minified. (Having it as a weak dependency means
// that we don't ship uglify etc with built apps just because
// boilerplate-generator uses spacebars-compiler.)
// XXX maybe uglify should be applied by this plugin instead of via magic
// weak dependency.
use: [
'caching-html-compiler',
'ecmascript',
'templating-tools'
],
sources: [
'plugin/compile-templates.js'
]
});
// This onUse describes the *runtime* implications of using this package.
Package.onUse(function (api) {
// XXX would like to do the following only when the first html file
// is encountered
api.addFiles('templating.js', 'client');
api.export('Template', 'client');
api.use('underscore'); // only the subset in packages/blaze/microscore.js
api.use('isobuild:compiler-plugin@1.0.0');
// html_scanner.js emits client code that calls Meteor.startup and
// Blaze, so anybody using templating (eg apps) need to implicitly use
// 'meteor' and 'blaze'.
api.use(['blaze', 'spacebars']);
api.imply(['meteor', 'blaze', 'spacebars'], 'client');
api.addFiles(['dynamic.html', 'dynamic.js'], 'client');
});