Open grabbou opened 10 years ago
I worry that they would be reactively re-run multiple times, which would re-replace and re-inherit, potentially overwriting any overrides that were defined between runs.
I still think it would be best to use additional template attributes for this (e.g., <template name="foo" inherits-helpers-from="bar">
), but as you said the core packages don't currently make this possible. It would be good to get a final verdict from MDG on whether they're willing to fold this package into blaze/templating packages, or whether we can do a PR to support tracking additional attributes that are added to template
tags. Since they now take feature requests on GitHub, I'll submit an issue.
Some time ago I also create a spaceless which removes all the whitespace. One idea I had then was that this could be simply an attribute on the template as well. So you could do <template spaceless="true">...</template>
. In general having custom annotations on the template could be helpful. So PR for any attributions become maybe simple values in template instance. So <template name="test" foo="bar">
would be the same as:
Template.test.created = function () {
this._foo = "bar";
};
Or maybe:
Template.test.created = function () {
this.attrs = {foo: "bar"};
};
Yep, this.attrs
is how I was picturing it working, too.
In addition to our talk:
Its quite hard to accomplish tag parsing the way you proposed, as long as there is no easy way to pass additional template tags to
Template.__define__
without rewriting entirehtml_scanner
.What about creating template helpers, like:
For
copyAs
it's not needed as 'pure' idea of having it is to avoid creating HTML file for a view that inherits from abstract one its properties.I've created sample UI helper for that:
and it works! :+1:
PR?