Add a new variable to getcontext method of a view

By extending the View File from an entry point file of an extension, you can transfer a new variable to the associated template file.

Sample code shown below

_.extend(HeaderMiniCartItemCellView.prototype, {
getContext: _.wrap(HeaderMiniCartItemCellView.prototype.getContext, function (fn) {
var context = fn.apply(this, _.toArray(arguments).slice(1));
	var isLoggedIn = ProfileModel.getInstance().get('isLoggedIn') === 'T';
					
	context.rate_formatted = this.model.get('rate_formatted')
	context.isLoggedIn = isLoggedIn;
return context;
	})
 }),		

Leave a comment

Your email address will not be published. Required fields are marked *