Skip to content
This repository has been archived by the owner on Dec 4, 2017. It is now read-only.

Bug 996526 - Backbone views to carry their own templates. #20

Merged
merged 1 commit into from Apr 17, 2014

Conversation

n1k0
Copy link
Contributor

@n1k0 n1k0 commented Apr 15, 2014

@n1k0 n1k0 mentioned this pull request Apr 15, 2014
*/
var BaseView = Backbone.View.extend({
var L10nView = (function() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this solution, I think it might lead to a bit of over-translation, but as we'll most likely need to watch performance anyway, I think we'll catch it if it gets too bad.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This a supremely great hack. That said, monkeypatching Backbone.View.extend() so that it can, in turn, monkeypatch every render method feels a little scary to me. Perhaps mostly because it feels like it causes render to do something slightly different and non-intuitive compared to what it does in normal views. This might be eased if L10Views were expected to implement something like localizedRender instead of render.

Or maybe I should just get over my discomfort and embrace the hack. :-)

Food for thought; your call on what you want to do here, if anything.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really felt like keeping the Backbone convention for rendering the views… The idea is that you can switch between L10nViews and regular ones while keeping the same API usage, which is great if you ask me.

@@ -41,7 +41,13 @@ loop.webapp = (function($, OT, webl10n) {
* as a `model` property.
*/
var ConversationFormView = sharedViews.BaseView.extend({
el: "#conversation-form",
template: _.template([
'<form>',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original HTML had an autocomplete="off" attribute. Any particular reason that's disappeared here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because it's no more necessary as the view is destroyed, created and rendered live instead of relying on the previous existing DOM state.

@dmose
Copy link
Member

dmose commented Apr 17, 2014

In general, this looks great.

One other comment: running the client-local tests now generates 9 "is undefined" warnings from [l10n] in the web console, whereas without the patch, there were just 5. I get that these are just warnings, but they do make it harder to locate the console messages that are actually worth acting in. If possible, it'd be great to get rid of these warnings. If it's more practical, just not regressing the number would be a reasonable start. If you tell me it's more pain than it's worth, I can live with that too.

r=dmose, with the comments addressed. As usual, please squash and add the r= notation to the commit message before merging.

@n1k0
Copy link
Contributor Author

n1k0 commented Apr 17, 2014

One other comment: running the client-local tests now generates 9 "is undefined" warnings from [l10n] in the web console, whereas without the patch, there were just 5

We still need to find a way to mock l10n in shared tests. That should be addressed in a dedicated PR though.

For now, most nits will be addressed in #22 to avoid rebasing and resolving too many conflicts for no good reason :)

Merging.

n1k0 added a commit that referenced this pull request Apr 17, 2014
Bug 996526 - Backbone views to carry their own templates. r=dmose
@n1k0 n1k0 merged commit 243f5c5 into master Apr 17, 2014
@n1k0 n1k0 deleted the bug-996526-view-templates branch April 17, 2014 08:11
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants