mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
This package was always included in apps, and even if it was possible to remove,
there wasn't a compelling story about when users would remove and replace
it. Plus, not all backwards-compatibility code could even live in it (eg, field
names of objects), so it was incomplete. It also introduced odd load order
constraints.
Instead, we introduce two conventions for backwards-compatibility code:
- Special comments of the form "// XXX COMPAT WITH 0.6.4"
- When feasible, put backwards-compatibility code in a file called
"deprecated.js" in the relevant package.
This is documented at:
https://github.com/meteor/meteor/wiki/Meteor-Style-Guide#deprecated-code-and-backwards-compatibility
Additionally, removed some symbols that existed for backwards compatibility with
Meteor 0.4.0 (changes made 10 months ago): Meteor.is_client, Meteor.is_server,
and (in a method) this.is_simulation.
68 lines
2.2 KiB
JavaScript
68 lines
2.2 KiB
JavaScript
|
|
|
|
if (Meteor.isClient) {
|
|
Template.page.nodespec = function (fn) {
|
|
var parts = [fn()];
|
|
var replaceParts = function(regex, replacementFunc) {
|
|
var newParts = [];
|
|
_.each(parts, function (part) {
|
|
if (typeof part !== 'string') {
|
|
newParts.push(part);
|
|
return;
|
|
}
|
|
regex.lastIndex = 0;
|
|
var charsTaken = 0;
|
|
var matchResult;
|
|
while ((matchResult = regex.exec(part))) {
|
|
var matchIndex = matchResult.index;
|
|
if (matchIndex > charsTaken)
|
|
newParts.push(part.substring(charsTaken, matchIndex));
|
|
charsTaken = regex.lastIndex;
|
|
var replacementParts = replacementFunc(matchResult);
|
|
newParts.push.apply(newParts, _.toArray(replacementParts));
|
|
}
|
|
if (charsTaken < part.length)
|
|
newParts.push(part.slice(charsTaken));
|
|
});
|
|
parts = newParts;
|
|
};
|
|
|
|
parts.unshift(['<div class="nodespec">']);
|
|
parts.push(['</div>']);
|
|
replaceParts(/".*?"/g, function (match) {
|
|
return [['<span class="str">', Handlebars._escape(match[0]), '</span>']];
|
|
});
|
|
replaceParts(/`(.*?)`/g, function (match) {
|
|
return [['<span class="token">', Handlebars._escape(match[1]), '</span>']];
|
|
});
|
|
replaceParts(/[A-Z]{3,}/g, function (match) {
|
|
return [['<span class="tokentype">', Handlebars._escape(match[0]), '</span>']];
|
|
});
|
|
replaceParts(/[a-z]\w*/g, function (match) {
|
|
return [['<span class="ref">', Handlebars._escape(match[0]), '</span>']];
|
|
});
|
|
replaceParts(/[\[\]()|.,*?]/g, function (match) {
|
|
return [['<span class="punc">'], match[0], ['</span>']];
|
|
});
|
|
replaceParts(/,/g, function (match) {
|
|
return [['<span class="comma">'], match[0], ['</span>']];
|
|
});
|
|
replaceParts(/\|/g, function (match) {
|
|
return [['<span class="or">'], match[0], ['</span>']];
|
|
});
|
|
|
|
var html = _.map(parts, function (part) {
|
|
if (typeof part === "string")
|
|
return Handlebars._escape(part);
|
|
return part.join('');
|
|
}).join('');
|
|
|
|
return new Handlebars.SafeString(html);
|
|
};
|
|
|
|
Template.page.spacer = function () {
|
|
return new Handlebars.SafeString('<div class="spacer"> </div>');
|
|
};
|
|
|
|
}
|