Set new content source for template.
@param {string|bb-value} source New content source for template.
343800
function(source){
      var oldSource = this.source;
      if (oldSource != source)
      {
        if (typeof source == 'string')
        {
          var m = source.match(/^([a-z]+):/);
          if (m)
          {
            source = source.substr(m[0].length);

            switch (m[1])
            {
              case 'id':
                // source from script element
                source = resolveSourceByDocumentId(source);
                break;
              case 'path':
                source = getSourceByPath(source);
                break;
              default:
                /** @cut */ basis.dev.warn(namespace + '.Template.setSource: Unknown prefix ' + m[1] + ' for template source was ingnored.');
            }
          }
        }

        if (oldSource && oldSource.bindingBridge)
        {
          this.url = '';
          this.baseURI = '';
          oldSource.bindingBridge.detach(oldSource, templateSourceUpdate, this);
        }

        if (source && source.bindingBridge)
        {
          if (source.url)
          {
            this.url = source.url;
            this.baseURI = path.dirname(source.url) + '/';
          }

          source.bindingBridge.attach(source, templateSourceUpdate, this);
        }

        this.source = source;

        templateSourceUpdate.call(this);
      }
    }
1220372
public void add(String name, Object value) {
		if (value != null) {
			this.content.put(name, value);
		}
	}
166872
public void setSourceContent(String aSourceFile, String aSourceContent) {
        String source = aSourceFile;
        if (this._sourceRoot != null) {
            source = Util.relative(this._sourceRoot, source);
        }

        if (aSourceContent != null) {
            // Add the source content to the _sourcesContents map.
            // Create a new _sourcesContents map if the property is null.
            if (this._sourcesContents == null) {
                this._sourcesContents = new HashMap<>();
            }
            this._sourcesContents.put(source, aSourceContent);
        } else if (this._sourcesContents != null) {
            // Remove the source file from the _sourcesContents map.
            // If the _sourcesContents map is empty, set the property to null.
            this._sourcesContents.remove(source);
            if (this._sourcesContents.isEmpty()) {
                this._sourcesContents = null;
            }
        }
    }
789285
public function setSource($key, $value)
    {
        $unit = $this->searchForId($key, true);

        $source = $this->getXPathFirstItem('xliff:source', $unit);

        // If already present check
        if ($source === null) {
            $source = $unit->appendChild($this->doc->createElementNS(self::NS, 'source'));
        } elseif ($source->firstChild) {
            // If already present, we have to remove the textnode if one exists as otherwise the value will get
            // appended.
            $source->removeChild($source->firstChild);
        }

        $source->appendChild($this->doc->createTextNode($value));
    }
115244
function (source) {
        //要解析的源码。To be parsed template source string.
        this.source = source;

        //当前处理的位置。Current parsed position of source.
        this.position = 0;

        //当前读取状态。Current read state, server or client.
        this.state = stateEnum.client;

        //标签计数器，规则：遇到开始标签 '<' push，遇到结束标签 '</' pop。Counter for tags, rule: if '<' push, if '</' pop.
        this.tags = [];

        //引号计数器，规则：当遇到了引号，且引号之前不是'\'时，若数组为空则push，若数组不为空且值与它相同则pop，push类型：{type: quotesEnum.xxx, position: xxx}。Counter for quotes.
        this.quotes = [];

        //左大括号计数器，规则：遇到 '{' push，遇到 '}' pop，push类型：{type: bracesEnum.xxx, position: xxx}。Counter for braces.
        this.braces = [];

        //左小括号计数器，规则：遇到 '(' push，遇到 ')' pop，push类型：position。Counter for brackets.
        this.brackets = [];
    }
175930
function replaceStringInAsset(asset, source, target) {
    const sourceRE = new RegExp(source, 'g');

    if (typeof asset === 'string') {
        return asset.replace(sourceRE, target);
    }

    // ReplaceSource
    if ('_source' in asset) {
        asset._source = replaceStringInAsset(asset._source, source, target);
        return asset;
    }

    // CachedSource
    if ('_cachedSource' in asset) {
        asset._cachedSource = asset.source().replace(sourceRE, target);
        return asset;
    }

    // RawSource / SourceMapSource
    if ('_value' in asset) {
        asset._value = asset.source().replace(sourceRE, target);
        return asset;
    }

    // ConcatSource
    if ('children' in asset) {
        asset.children = asset.children.map(child => replaceStringInAsset(child, source, target));
        return asset;
    }

    throw new Error(
        `Unknown asset type (${asset.constructor.name})!. ` +
            'Unfortunately this type of asset is not supported yet. ' +
            'Please raise an issue and we will look into it asap'
    );
}
779671
function set(url, content, mimeType) {
			if (url.charAt(0) !== '/') { url = '/'+url; }
			var point = getPoint(url) || new KnownPoint(url);
			// console.info('new url:',url, mimeType);
			point.content = content;
			point.mimeType = mimeType;
    }
592241
private void setTemplate(CmsResource siteRootResource) {

        try {
            m_cms.lockResource(siteRootResource);
            // add template  property
            if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(m_template)) {
                CmsProperty prop = new CmsProperty(CmsPropertyDefinition.PROPERTY_TEMPLATE, m_template, m_template);
                m_cms.writePropertyObject(siteRootResource.getRootPath(), prop);
            }
            m_cms.unlockResource(siteRootResource);
        } catch (CmsException e) {
            LOG.error("Error on adding template", e);
        }
    }
1255089
@VisibleForTesting
  public void setSource(PropertyKey key, Source source) {
    mSources.put(key, source);
  }
156319
function setAsyncContent(event) {

            that._content.innerHTML = event.response;

            /**
             * Event emitted when the content change.
             * @event ch.Content#contentchange
             * @private
             */
            that.emit('_contentchange');

            /**
             * Event emitted if the content is loaded successfully.
             * @event ch.Content#contentdone
             * @ignore
             */

            /**
             * Event emitted when the content is loading.
             * @event ch.Content#contentwaiting
             * @example
             * // Subscribe to "contentwaiting" event.
             * component.on('contentwaiting', function (event) {
             *     // Some code here!
             * });
             */

            /**
             * Event emitted if the content isn't loaded successfully.
             * @event ch.Content#contenterror
             * @example
             * // Subscribe to "contenterror" event.
             * component.on('contenterror', function (event) {
             *     // Some code here!
             * });
             */

            that.emit('content' + event.status, event);
        }
889694
public ImageLayer setSource (TileSource source) {
    if (source.isLoaded()) setTile(source.tile());
    else source.tileAsync().onSuccess(new Slot<Tile>() {
      public void onEmit (Tile tile) { setTile(tile); }
    });
    return this;
  }
611837
function(template) {
            var self = this;
            this.template = template || this.template;
            Resources.load(this.options.loader, this.template).then(function(content) {
                self.setContent(content);
                self.trigger("loaded");
            }, function() {
                self.setContent(null);
                self.trigger("error");
            });
            return this;
        }
1056681
function updateDOM(source,target,scope,actions,view=target,template=source) {
		Object.defineProperty(target,"view",{enumerable:false,configurable:true,writable:true,value:view});
		Object.assign(scope,{"$source":source,
												"$target":target,
												"$template":template.children ? (template.children.length> 1 ? template.children : template.children[0]) : template,
												"$view":view.children.length> 1 ? view.children : view.children[0]});
		// if source and target are text
		if(typeof(source)==="string") {
			const value = (resolve(source,scope,actions)+""),
					doc = new DOMParser().parseFromString(value, "text/html"),
		  		children = slice(doc.body.childNodes);
		  if(children.some(node => node.nodeType === 1)) {
		  	updateDOM(toVDOM(doc.body),doc.body,scope,actions,view,template);
		  	let parent;
		  	if(target.nodeType===3) {
			  	parent = target.parentElement;
			  	parent.removeChild(target);
		  	} else if(target.nodeType===1) {
		  		parent = target;
		  		while(parent.lastChild) parent.removeChild(parent.lastChild);
		  	}
		  	slice(doc.body.childNodes).forEach(child => parent.appendChild(child));
		  } else if(target.data!==value) {
		  	target.data = value;
		  }
		  return view;
		}
		target.view.template = target.view.innerHTML;
		// if tags aren't the same
		if(source.tagName!==target.tagName) {
			// replace the target with the source
			if(target.parentNode) {
				const el = document.createElement(source.tagName);
				target.parentNode.replaceChild(el,target);
				target = el;
			}
		}
		// loop through target attributes, remove where does not exist in source
			slice(target.attributes).forEach(attribute => source.attributes[attribute.name]!==null || target.removeAttribute(attribute.name));
			// loop through source attributes
			let directed;
			Object.keys(source.attributes).forEach(aname => {
				let value = source.attributes[aname],
				 type = typeof(value),
				 currentview = CURRENTVIEW;
				CURRENTVIEW = target;
				const dname = resolve(aname.split(":")[0],scope,actions),
					directive = directives[dname]||tlx.directives[dname];
				value = resolve(value,scope,actions);
				CURRENTVIEW = currentview;
				type = typeof(value);
				// replace different
				if(value==null) {
					target.removeAttribute(aname);
					delete target[aname];
				} else if(["boolean","number","string"].includes(type)) {
					if(value!==target.getAttribute(aname)) {
						try {
							target.setAttribute(aname,value);
							if(aname==="value") target.value = value;
						} catch(e) {
							; // just ignore, may be an attribute with an unresolved argument, e.g. t-bind:${aname}
						}
					}
				} else {
						const pname = toPropertyName(aname);
						if(value!==target[pname]) target[pname] = value;
				}
				if(directive) { 
					while(target.lastChild) target.removeChild(target.lastChild); 
					const render = (scope,actions) => {
						source.children.forEach(child => {
							if(typeof(child)==="string") target.appendChild(new Text(child));
							else target.appendChild(document.createElement(child.tagName));
							updateDOM(child,target.lastChild,scope,actions,view,template);
						});
						return target;
					};
					const result = directive(value,scope,actions,render,{element:target,raw:aname,resolved:aname.indexOf("${")>=0 ? resolve(aname,scope,actions) : aname}),
						rtype = typeof(result);
					if(result==null) {
						target.parentElement.removeChild(target);
					} else if(rtype==="string") {
							directed = true;
							target.innerHTML = result;
					} else if(rtype==="object" && result instanceof HTMLElement) {
						directed = true;
						if(result!==target) target.parentElement.replaceChild(result,target);
					}
				}
			});
			if(!directed) {
				// remove extra children
				let remove = target.childNodes.length-source.children.length;
				while(remove-->0) !target.lastChild || target.removeChild(target.lastChild);
				// handle the child nodes
				let targets = slice(target.childNodes,0,source.children.length);
				if(targets.length===0) {
					const shadow = target.shadowRoot;
					if(shadow) targets = slice(shadow.childNodes,0,source.children.length);
				}
				source.children.forEach((child,i) => {
					// update if in range
					if(i<targets.length) {
						updateDOM(child,targets[i],scope,actions,view,template);
						return;
					}
					if(typeof(child)==="string") target.appendChild(new Text());
					else target.appendChild(document.createElement(child.tagName));
					updateDOM(child,target.lastChild,scope,actions,view,template);
				});
			}
		
		return view;
	}
1219163
def addSourceId(self, value):
        '''
        '''
        if isinstance(value, Source_Id):
            self.source_ids.append(value)
        else:
            raise (TypeError,
                   'source_id Type should be Source_Id, not %s' % type(source_id))
1304394
public function setSource($source): void
    {
        if (!\is_string($source)) {
            throw new Grid\GridException('Source of `SqlSource` should be string with SQL query');
        }
        parent::setSource($source);
    }
676440
function set_text($source, $from_file = false)
    {
        if ($from_file && file_exists($source)) {
            $this->text = file_get_contents($source);
        }
        else {
            $this->text = $source;
        }

        $this->_converted = false;
    }
1237375
function(name, source){
      var oldSource = this.sources[name];

      if (name in this.fields.sources == false)
      {
        /** @cut */ basis.dev.warn('basis.data.object.Merge#setSource: can\'t set source with name `' + name + '` as not specified by fields configuration');
        return;
      }

      // ignore set source for self fields
      if (name == '-')
        return;

      // create context for name if not exists yet
      if (name in this.sourcesContext_ == false)
        this.sourcesContext_[name] = {
          host: this,
          name: name,
          adapter: null
        };

      // resolve object from value
      source = resolveObject(this.sourcesContext_[name], resolveSetSource, source, 'adapter', this);

      // main part
      if (oldSource !== source)
      {
        var listenHandler = this.listen['source:' + name];

        // remove handler from old source if present
        if (oldSource)
        {
          if (listenHandler)
            oldSource.removeHandler(listenHandler, this);

          oldSource.removeHandler(MERGE_SOURCE_HANDLER, this.sourcesContext_[name]);
        }

        // set new source value
        this.sources[name] = source;

        // add handler to new source
        if (source)
        {
          source.addHandler(MERGE_SOURCE_HANDLER, this.sourcesContext_[name]);

          if (listenHandler)
            source.addHandler(listenHandler, this);

          // apply new source data
          var newData = this.fields.sources[name](source.data);

          // reset properties missed in new source if source is defaultSource
          if (this.fields.defaultSource == name)
            for (var key in this.data)
              if (!this.fields.fieldSource.hasOwnProperty(key) && !newData.hasOwnProperty(key))
                newData[key] = undefined;

          this.update(newData);
        }

        this.emit_sourceChanged(name, oldSource);
      }
    }