Replace templates:tabs Atmosphere package with inline Blaze implementation

Drop the templates:tabs dependency as part of Meteor 3.0 migration prep.
The package is replaced by a lightweight inline basicTabs/tabContent
template pair with identical API, so no consumer template changes needed.
This commit is contained in:
Harry Adel 2026-03-05 05:31:13 +02:00
parent ff7729fc35
commit 81d3a08b9b
7 changed files with 91 additions and 7 deletions

View file

@ -0,0 +1,50 @@
const { ReactiveVar } = require('meteor/reactive-var');
Template.basicTabs.onCreated(function () {
const activeTab = this.data.activeTab
? { slug: this.data.activeTab }
: this.data.tabs[0];
this._activeTab = new ReactiveVar(activeTab);
this.isActiveSlug = (slug) => {
const current = this._activeTab.get();
return current && current.slug === slug;
};
});
Template.basicTabs.helpers({
isActiveTab(slug) {
if (Template.instance().isActiveSlug(slug)) {
return 'active';
}
},
});
Template.basicTabs.events({
'click .tab-item'(e, t) {
t._activeTab.set(this);
},
});
function findBasicTabsInstance() {
let view = Blaze.currentView;
while (view) {
if (view.name === 'Template.basicTabs' && view.templateInstance) {
const inst = view.templateInstance();
if (inst && inst.isActiveSlug) {
return inst;
}
}
view = view.parentView;
}
return null;
}
Template.tabContent.helpers({
isActiveTab(slug) {
const inst = findBasicTabsInstance();
if (inst && inst.isActiveSlug(slug)) {
return 'active';
}
},
});