Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trim input on noel applyTemplate. (Fix #387) #391

Merged
merged 4 commits into from Oct 21, 2013

Conversation

ssafejava
Copy link
Collaborator

No description provided.

@godknowsiamgood
Copy link

Guys, when this patch will be merged? Thanks.

@SBoudrias
Copy link
Collaborator

LGTM, I like the fix going to native trim for Node. @tbranyen ?

@@ -90,7 +90,8 @@ var LayoutManager = Backbone.View.extend({
if (_.isString(rendered)) {
// If no container is specified, we must replace the content.
if (manager.noel) {
rendered = $.parseHTML(rendered, true);
var trimmed = rendered.trim ? rendered.trim() : $.trim(rendered);
Copy link
Collaborator

Choose a reason for hiding this comment

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

We could cache the version of trim we want to use:

var trim = String.prototype.trim ?
  _.bind(String.prototype.trim.call, String.prototype.trim) :
  $.trim;

@ssafejava
Copy link
Collaborator Author

I moved the trim into renderTemplate so it will be applied on all template functions, including those defined directly on views. I thought this was clearer than moving it onto fetchTemplate as it would not work in situations such as the test at the bottom of views.js. Putting it in renderTempate also prevents the trim() call from being overridden by the common fetchTemplate override that caches templates in a global JST object.

tbranyen added a commit that referenced this pull request Oct 21, 2013
Trim input on noel applyTemplate. (Fix #387)
@tbranyen tbranyen merged commit ebed0c1 into tbranyen:master Oct 21, 2013
@tbranyen tbranyen deleted the applyTemplateTrim branch October 21, 2013 03:36
@tbranyen
Copy link
Owner

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants