Skip to content

Commit

Permalink
Revert "feat(Meteor0.8.3): Support Meteor 0.8.3 and prior for ngMeteo…
Browse files Browse the repository at this point in the history
…r v0.2"

This reverts commit 27382bb, as it
seems to be causing issues on 0.8.3 and on versions prior to 0.8.2.
  • Loading branch information
leoetlino committed Aug 25, 2014
1 parent ecae371 commit 21e6839
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 25 deletions.
40 changes: 17 additions & 23 deletions modules/ngMeteor-template.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var ngMeteorTemplate = angular.module('ngMeteor.template', []);
ngMeteorTemplate.run(['$templateCache',
function ($templateCache) {
angular.forEach(Template, function (template, name) {
if (name.charAt(0) != "_" && name != "prototype" && name != "loginButtons") { // Ignores templates with names starting with "_"
if (name.charAt(0) != "_") { // Ignores templates with names starting with "_"
$templateCache.put(name, '<ng-template name="' + name + '"></span>');
}
});
Expand All @@ -16,34 +16,28 @@ ngMeteorTemplate.directive('ngTemplate', ['$templateCache',
restrict: 'E',
scope: true,
template: function (element, attributes) {
var name = attributes.name,
template = Template[name],
templateRender = template.render(),
templateString = null;

// Check if version prior 0.8.3
if (Template[attributes.name].render){
var name = attributes.name,
template = Template[name],
templateRender = Blaze.toHTML(template),
templateString = null;

// Check for nested templates in the render object and replace them with the equivalent ngTemplate directive.
angular.forEach(templateRender, function (v, k) {
if (angular.isObject(v)) {
if (v._super) {
var transcludeTemplateName = v._super.kind.replace('Template_', '');
templateRender[k] = new HTML.Raw($templateCache.get(transcludeTemplateName));
}
// Check for nested templates in the render object and replace them with the equivalent ngTemplate directive.
angular.forEach(templateRender, function (v, k) {
if (angular.isObject(v)) {
if (v._super) {
var transcludeTemplateName = v._super.kind.replace('Template_', '');
templateRender[k] = new HTML.Raw($templateCache.get(transcludeTemplateName));
}
});

if (angular.isDefined(template)) {
templateString = UI.toHTML(templateRender);
} else {
throw new ReferenceError("There is no Meteor template with the name '" + name + "'.");
}
});

return templateString;
if (angular.isDefined(template)) {
templateString = UI.toHTML(templateRender);
} else {
return Blaze.toHTML(Template[attributes.name]);
throw new ReferenceError("There is no Meteor template with the name '" + name + "'.");
}

return templateString;
},
link: function (scope, element, attributes) {
var name = attributes.name,
Expand Down
4 changes: 2 additions & 2 deletions ngMeteor.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ angular.element(document).ready(function () {
}

// Recompiles whenever the DOM elements are updated.
var notifyParented = Blaze.View.notifyParented;
Blaze.View.notifyParented = function () {
var notifyParented = UI.Component.notifyParented;
UI.Component.notifyParented = function () {
notifyParented.apply(this, arguments);
if (this.region) {
Deps.afterFlush(function() {
Expand Down

0 comments on commit 21e6839

Please sign in to comment.