dist/ember-template-compiler.js in ember-source-1.0.0.rc5.1 vs dist/ember-template-compiler.js in ember-source-1.0.0.rc6
- old
+ new
@@ -1,9 +1,9 @@
(function() {
var Ember = { assert: function() {} };
-// Version: v1.0.0-rc.5-2-g9dc4ad8
-// Last commit: 9dc4ad8 (2013-07-25 20:19:21 -0400)
+// Version: v1.0.0-rc.6-1-g42f0c68
+// Last commit: 42f0c68 (2013-06-23 15:43:35 -0400)
(function() {
/**
@module ember
@@ -53,10 +53,74 @@
delete hashType[prop];
}
}
}
+/**
+ Register a bound helper or custom view helper.
+
+ ## Simple bound helper example
+
+ ```javascript
+ Ember.Handlebars.helper('capitalize', function(value) {
+ return value.toUpperCase();
+ });
+ ```
+
+ The above bound helper can be used inside of templates as follows:
+
+ ```handlebars
+ {{capitalize name}}
+ ```
+
+ In this case, when the `name` property of the template's context changes,
+ the rendered value of the helper will update to reflect this change.
+
+ For more examples of bound helpers, see documentation for
+ `Ember.Handlebars.registerBoundHelper`.
+
+ ## Custom view helper example
+
+ Assuming a view subclass named `App.CalenderView` were defined, a helper
+ for rendering instances of this view could be registered as follows:
+
+ ```javascript
+ Ember.Handlebars.helper('calendar', App.CalendarView):
+ ```
+
+ The above bound helper can be used inside of templates as follows:
+
+ ```handlebars
+ {{calendar}}
+ ```
+
+ Which is functionally equivalent to:
+
+ ```handlebars
+ {{view App.CalendarView}}
+ ```
+
+ Options in the helper will be passed to the view in exactly the same
+ manner as with the `view` helper.
+
+ @method helper
+ @for Ember.Handlebars
+ @param {String} name
+ @param {Function|Ember.View} function or view class constructor
+ @param {String} dependentKeys*
+*/
Ember.Handlebars.helper = function(name, value) {
+ if (Ember.Component.detect(value)) {
+ Ember.assert("You tried to register a component named '" + name + "', but component names must include a '-'", name.match(/-/));
+
+ var proto = value.proto();
+ if (!proto.layoutName && !proto.templateName) {
+ value.reopen({
+ layoutName: 'components/' + name
+ });
+ }
+ }
+
if (Ember.View.detect(value)) {
Ember.Handlebars.registerHelper(name, function(options) {
Ember.assert("You can only pass attributes as parameters (not values) to a application-defined helper", arguments.length < 2);
makeBindings(options);
return Ember.Handlebars.helpers.view.call(this, value, options);
\ No newline at end of file