Commit Graph

5992 Commits

Author SHA1 Message Date
David Greenspan
cf9bc604b8 Start of spacebars compiler reorg
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.
2014-01-15 10:17:41 -08:00
David Greenspan
3a99ea672b minor clean-up 2014-01-15 07:26:40 -08:00
David Greenspan
df6e954b4e Fix DomBackend to access jQuery consistently
Shouldn't use both `window.$` and `Package.jquery.jQuery`
2014-01-15 06:22:18 -08:00
David Greenspan
9f6e51ebc1 Improve a comment 2014-01-15 06:22:18 -08:00
Avital Oliver
da2a17f80d Use custom attribute handler for 'value' and 'checked'.
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
2014-01-14 19:29:55 -08:00
Avital Oliver
06c0a9d8aa Test that template in DOM before rendered callback fires 2014-01-14 16:39:54 -08:00
David Greenspan
56e94821e3 Spacebars: better errors, comment handling
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
2014-01-13 13:04:27 -08:00
David Greenspan
d1f366b30b mv spacebars.js spacebars-compiler.js 2014-01-11 22:06:09 -08:00
David Greenspan
9cd2349d08 fix getContainingComponent (and some tests)
stuff I missed when changing domrange
2014-01-10 14:38:14 -08:00
Avital Oliver
07a74ca03f observe-sequence: test for string array transition 2014-01-10 15:56:17 -05:00
Avital Oliver
fa356ec797 observe-sequence: fix non-string ids 2014-01-10 15:44:42 -05:00
David Greenspan
cd6387cc02 Clean up DomRange, phase 1
- 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
2014-01-09 20:23:35 -08:00
David Greenspan
7e7f29c550 Perform template optimization in <body> too 2014-01-08 13:09:57 -08:00
David Greenspan
45494d22a0 mark old README 2014-01-08 11:28:38 -08:00
David Greenspan
d6583a14e6 mv README 2014-01-08 11:28:05 -08:00
David Greenspan
b9455835c3 add example to html-tools README 2014-01-08 11:24:11 -08:00
David Greenspan
4b9230b075 Give Spacebars its own JS token parsers
Fixes `{{foo '"'}}`.

Breaks dependency on `jsparse`.
2014-01-07 10:15:07 -08:00
Avital Oliver
5dbeb2b911 Simplify a line of code 2014-01-07 04:40:53 -08:00
Avital Oliver
32849891ba Allow {{#each}} over array with undefined items 2014-01-07 04:40:34 -08:00
Avital Oliver
4e8d858923 Rethrow contextualized error in {{#each}}
...in case the argument is a cursor with {fields: {_id: 0}}
2014-01-07 04:37:14 -08:00
Avital Oliver
e3578c6c30 Merge branch 'devel' into shark
Conflicts:
	packages/minimongo/minimongo.js
	packages/minimongo/package.js
2014-01-07 04:08:06 -08:00
Avital Oliver
2e88f7a758 Improve observe-sequence item matching heuristic
- 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.
2014-01-07 03:00:10 -08:00
David Greenspan
5ed450921d More wordsmithing 2014-01-06 21:38:39 -08:00
David Greenspan
f50e0a4973 prose edits 2014-01-06 21:29:10 -08:00
David Greenspan
40d4d9cd84 document html-tools 2014-01-06 21:25:40 -08:00
David Glasser
add4f6e015 Disallow {fields:{_id:0}} in observeChanges
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.
2014-01-06 21:16:23 -08:00
David Greenspan
32b60177a1 Remove source files from readme 2014-01-06 17:34:42 -08:00
David Greenspan
b9877c7a53 List source files in htmljs readme 2014-01-06 17:26:31 -08:00
David Glasser
8800564e80 Use OplogObserveDriver for most selectors.
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.)
release/release/oplog-with-operators
2014-01-06 17:02:04 -08:00
Avital Oliver
95130ad760 observe-sequence: simplify and optimize by not fetching cursors that change 2014-01-06 16:05:27 -08:00
David Greenspan
fe08fa7471 Fix ellipsis in error display; test errors 2014-01-06 15:54:23 -08:00
David Greenspan
27118d4b5a Improve error message for <input></input>
...and other cases where we see an unexpected HTML end tag.  We'd previously say "Expected EOF", among other things.
2014-01-06 15:41:51 -08:00
Emily Stark
c74dd9aa62 Add missing 'random' dependency to retry 2014-01-06 15:14:39 -08:00
David Greenspan
1f25f2a824 fix more Spacebars errors 2014-01-06 15:01:15 -08:00
David Greenspan
b42112e3e6 tweaks 2014-01-06 14:37:13 -08:00
David Greenspan
df0e414193 Route Spacebars errors properly
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.
2014-01-06 13:48:31 -08:00
David Greenspan
2577b87cb1 Fix typo (spotted by cscott) 2014-01-06 11:39:42 -08:00
David Greenspan
e04edf1ca0 Finish documenting htmljs package 2014-01-05 17:29:01 -08:00
David Greenspan
47596a28ad minor edits 2014-01-05 10:30:44 -08:00
David Greenspan
a6b3a431b2 further internal docs and cleanup 2014-01-03 17:27:17 -08:00
David Glasser
4f7d14c1f2 Upgrade websocket-driver to 0.3.2
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).
2014-01-03 17:19:59 -08:00
David Glasser
feac6f03e3 Merge branch 'minimongo-array-updates' into devel
Actually implement updating field 'x.$.y'! Also some related cleanups.
release/mongo-refactor
2014-01-02 23:51:23 -08:00
David Glasser
82739804b8 Implement '$' update for $elemMatch 2014-01-02 23:49:51 -08:00
David Glasser
2063999ce0 Implement '$' update for $near 2014-01-02 23:36:26 -08:00
David Glasser
e3e9cca12a Implement 'a.$.b' modifier
Does not yet work with $near or $elemMatch
2014-01-02 23:00:18 -08:00
David Glasser
5c9e58f2af clean up findModTarget
convert arguments to options
2014-01-02 22:38:50 -08:00
David Glasser
b2e3b08248 Cleanup/modernization of modify.js 2014-01-02 22:07:37 -08:00
David Glasser
0f7e0b54ca Refactor: optionify LocalCollection._modify arg 2014-01-02 21:47:24 -08:00
David Glasser
a8d1798e88 JSON -> EJSON in test 2014-01-02 21:45:13 -08:00
David Glasser
02aad697d7 remove random type tag in test 2014-01-02 21:42:51 -08:00