Comments (17)
This will almost certainly mean making it an error to assign helpers in the super old pre-1.0 way. But we've been warning about that for over a year now so it's probably OK.
from guide.
@mitar I see that Blaze Components already have this feature: https://github.com/peerlibrary/meteor-blaze-components#namespaces
Do you see any problems with adding this to core templates?
from guide.
Hmm, if I remember correctly, there were quite some edge cases to cover.
First, probably it would be easiest to simply make templates be accessible under Template['a.b.c']
. Uglier, but should just works.
Then the question becomes can Template.a
also be at the same time another template or not. In Blaze Components it can. So namespace of namespaces is different from namespace of templates. Pretty useful.
Then some things should be fixed:
And Spacebars.dot
has to be monkey-patched: https://github.com/peerlibrary/meteor-blaze-components/blob/master/lib.coffee#L35
So the hard problem is {{> a.b.c}}
. That one has to be supported correctly. And potentially (not in Blaze Components) b
could even be a helper returning a namespace.
So yea, it can be done, but I think some more work has to be done. Question is, should we all just move to Blaze Components instead. ;-)
from guide.
I don't feel like #4230 or #4232 are blockers for specifically this issue. They are all bugs related to dots and templates, but I'm not talking about rendering templates returned from helpers here. I'm planning to just add a thing that says "check a.b.c in its entirety against the space of available templates."
from guide.
Imho its an issue with Meteor templates namespacing / scoping in general - Theres no way for two packages to export ui components. (should be treated as symbols/js objects - this is something handled better in the react pattern, where you have more control + can extend components etc. more easily)
from guide.
This is why I am proposing that templates are exported as whole names, so Template['a.b.c']
. Then one package can export Template['a.b']
and another Template['a.d']
. BTW, exporting various components from various packages of course works much better in Blaze Components which have a separate concept of a namespace. (So you can have both Template.a
as a template and Template.a.b
as a template.
from guide.
I guess we are not going to do this in the end.
from guide.
Why not?
from guide.
I could maybe take it if someone has a nice PR (I can't remember if there is or not) but it seems simpler to just make an exception for templates and namespace them with underscores rather than writing a bunch of code just to make the separators dots. Plus, underscores have the nice advantage over dots in JS that they don't need to be put in quotes and brackets when accessing a template.
from guide.
One more reason to use Blaze Components then. ;-)
from guide.
Sure!
from guide.
We could just have "Template" be scoped to package or app.
import { Template as accountTemplate } from 'mdg:accounts-ui'
Template.main.helpers({
logout: accountsTemplates.logout
});
or
import { myTemplate } from './my-template.html'
myTemplate.helpers({
foo: () => 'bar'
});
export { myTemplate }
from guide.
Yes but all of that requires additional code to be written - namespacing via underscores doesn't.
from guide.
So, we get again back to the question of how much time does MDG want to invest into improving the platform, or are we just stuck with what we have.
from guide.
Like, the point of Meteor Development Group is to develop, no?
from guide.
I mean if you want to get technical then the word "develop" doesn't just mean writing code. We're investing literally all of our time improving the platform, we just don't currently think that spending a week making templates work via import/export is the highest priority right now.
from guide.
And what is the priority? Still just Galax?
Maybe then guide should recommend Blaze Components? If you do not have time to invest to make bare Blaze improved, which is OK, then start promoting projects which do that? I thought the agreement was that because we can modify Blaze according to some ideas from Blaze Components, we can then cover common cases.
But maybe Blaze Components is the way what should be promoted in the guide:
- it fixes the issues of
this
in helper and event handlers - it moves development to components, so conceptually it will be easier for people to later on move to React
- if makes things reusable
- provides namespaces
- solves many other small discrepancies
- it is much more performant than Blaze because it does not recompute everything on every data context change.
from guide.
Related Issues (20)
- [hexo] Cannot start local hexo server "unknown block tag: endraw"
- Link to OK Grow article for MongoDB Atlas oplog tailing no longer works HOT 2
- Add Windows getting started guide HOT 1
- Section 6 - Running on Mobile - 404 HOT 2
- Remove or improve the part about crosswalk HOT 3
- Add section about eager loading of files
- Can't use Tailwind CSS v2.0 because postcss@^8.0.9 is not supported by juliancwirko:postcss HOT 1
- Add page last updated date? HOT 1
- angular is not supported HOT 3
- Helmet Example Link is now a 404 HOT 4
- missing meteor test --drive-package information HOT 3
- Update testing section with Cypress HOT 2
- A list of meteor URLs needed to be added for a corporate proxy whitelist HOT 1
- Update Guide to explain 1.7's new lazy loading capabilities HOT 5
- Add testing with Cypress to the guide HOT 5
- Documentation error in the Meteor guide Method section. HOT 1
- Blank screen issue on android mobile with meteor version 1.7 HOT 2
- Improve Vue page HOT 1
- Action Required: Fix Renovate Configuration
- Add to TypeScript section HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from guide.