Github user tbouron commented on a diff in the pull request:
https://github.com/apache/brooklyn-ui/pull/113#discussion_r235922436
--- Diff:
ui-modules/utils/script-tag-non-overwrite/script-tag-non-overwrite.js ---
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import angular from 'angular';
+
+/**
+ * If included, this decorates the default angular `<script>` tag so that
it checks the
+ * template cache and does _not_ put the contents of the `script` into the
cache if there
+ * is already an element with that ID present.
+ */
+
+const MODULE_NAME = 'brooklyn.components.script-tag-non-overwrite';
+
+angular.module(MODULE_NAME, [])
+ .decorator('scriptDirective', ['$delegate', '$templateCache',
scriptTagDirectiveDecorator]);
+
+export default MODULE_NAME;
+
+const BROOKLYN_CONFIG = 'brooklyn.config';
+
+function scriptTagDirectiveDecorator($delegate, $templateCache) {
+ let base = $delegate[0];
+ return [ Object.assign({}, base, { compile: function(el, attr) {
+ let match = $templateCache.get(attr.id);
+ if (!(match === null || typeof match === 'undefined')) {
--- End diff --
@ahgittin Aye, that was the use-case I had in mind. I don't think it's
strictly speaking required but better safe than sorry => I think it would be
better to do this change.
Although, there is another solution that is even simpler: don't decorate
the `script` directive and update the way we register template to do that in a
` .config` block (like the main template) rather than using `<script>` tags
---