In advance of changing how {{> }} and {{# }} are compiled.
Goals for this reorg:
- "stache tags" are instanceof Spacebars.TemplateTag
- Phase out the word "stache"
- Better separate parsing, template tag expansion, and overall codegen and optimization using multiple files, and additional methods and properties on TemplateTag as appropriate
In particular, the things that happen to a template tag are it is parsed; validated (i.e. errors are thrown); and expanded (into code). Validation and expansion can be methods on TemplateTag, as long as they also know the TEMPLATE_TAG_POSITION where the tag occurred. They can be done either while parsing or while walking the AST for code generation, but if validation is done during parsing then it's easy to throw good error messages. If expansion is done during code generation, then it's easier to inspect the parse tree for testing and debugging.
Also:
- Get rid of the word "Special" in html-tools (HTML.Special, getSpecialTag) in favor of TemplateTag.
Setting these attribute on DOM elements only affects their initial
state. Instead, one should set the JavaScript property on the
DOM element directly.
Fixes#1752
Give better errors (and in some cases, errors at all) for cases like:
- `<a {{{x}}}>`
- `<a {{#if x}}foo{{/if}}>`
- `<a {{k}}={{v}}>`
- `<a x{{y}}=z>`
Also, allow comments (`{{! x}}`) anywhere a non-comment tag is allowed
- Get rid of DomRange "host objects" (too confusing)
- start to use `r instanceof DomRange` instead of `'dom' in r`
Ported domrange tests; all tests pass
- If the items in an array are strings or numbers, use those as
the id.
- If the items in an array are objects with no '_id' field, use
the index in the array.
- In any case, if the id to be used is already present in this array,
generate a random replacement value and print a warning.
This implies it is not allowed in `observe` either, or in cursors
returned from publish functions, or in cursors used in {{#each}}
Why? observeChanges and DDP publication use the ID as part of the
callback/message, and eliding it completely breaks them. Meteor UI uses
the ID with {{#each}} to properly move nodes around instead of
re-rendering. We could try to allow it for `observe` outside of
{{#each}}, but it would feel somewhat inconsistent.
Previously OplogObserveDriver was only used for selectors which
performed equality checks against scalars. Now that we believe minimongo
to be more robust in the face of more MongoDB edge cases, we use
OplogObserveDriver (if configured) for any selector that minimongo can
compile except those containing $near or $where.
(We still do not use OplogObserveDriver for cursors with skip or limit.)
Now Spacebars syntax errors (as well as html_scanner errors) go through proper error reporting channels rather than throwing exceptions. For simple cases, we are back to showing nice errors like Handlebars did on devel, with context.
Next: Comb the spacebars compiler for errors that are thrown or lack good line numbers. Go through our own list of bad error messages.
This lowers the max websocket frame length from 1GB to 64MB.
Note that due to #1648, this may not immediately affect existing
checkouts of meteor (but will get into all release builds).