creates a toast or tile binding template given the name and a specific number of text and image elements
493423
function (name, imageCount, textCount) {
	// contains placeholder for optional binding attributes
	// contains placeholder for each text and image payload
	var template = '<binding template="' + name + '"%s>';
	for (var i = 0; i < imageCount; i++)
		template += '<image id="' + (i + 1) + '" src="%s" alt="%s"/>';
	for (var i = 0; i < textCount; i++)
		template += '<text id="' + (i + 1) + '">%s</text>';
	template += '</binding>';

	return template;
}
1102202
function getBindingsFromTemplateProperties(oElement) {
		var aPropertiesKeys = Object.keys(oElement.getMetadata().getAllProperties());

		return aPropertiesKeys
			.filter(function (sPropertyName) {
				return sPropertyName in oElement.mBindingInfos;
			})
			.reduce(function (aBindings, sPropertyName) {
				return aBindings.concat(
					flattenBindingsFromTemplate(
						oElement.mBindingInfos[sPropertyName]
					)
				);
			}, []);
	}
1650
function createDomElementFromTemplate(html) {
    //match container markers like <@element/>
    let containerTags = html.match(rContainerGlobal) || [];

    for (let containerTag of containerTags) {
        let [, containerName, attrs = ''] = rContainer.exec(containerTag);
        let template = `<script type="x" ${ATTR}="${containerName}">${attrs.trim()}</script>`;

        html = html.split(containerTag).join(template);
    }

    //match attribute markers like <span @element></span>
    let allTags = html.match(rTags) || [];

    for (let tag of allTags) {
        let result = rAttr.exec(tag);

        if (result) {
            let elName = result[1];
            html = html.split(tag).join(tag.replace(`@${elName}`, `${ATTR}="${elName}"`));
        }
    }

    return $.create(html.trim());
}
1170180
protected String generateJS(final TextTemplate textTemplate)
	{
		final Map<String, Object> variables = new HashMap<>();
		variables.put("componentId", this.component.getMarkupId());
		textTemplate.interpolate(variables);
		return textTemplate.asString();
	}
54437
function (oRecord, index) {
    // Template is already available
    if(this._elTrTemplate) {
        return this._elTrTemplate;
    }
    // Template needs to be created
    else {
        var d   = document,
            tr  = d.createElement('tr'),
            td  = d.createElement('td'),
            div = d.createElement('div');
    
        // Append the liner element
        td.appendChild(div);

        // Create TD elements into DOCUMENT FRAGMENT
        var df = document.createDocumentFragment(),
            allKeys = this._oColumnSet.keys,
            elTd;

        // Set state for each TD;
        var aAddClasses;
        for(var i=0, keysLen=allKeys.length; i<keysLen; i++) {
            // Clone the TD template
            elTd = td.cloneNode(true);

            // Format the base TD
            elTd = this._formatTdEl(allKeys[i], elTd, i, (i===keysLen-1));
                        
            df.appendChild(elTd);
        }
        tr.appendChild(df);
        this._elTrTemplate = tr;
        return tr;
    }   
}
223075
def template(src, context=binding)
      eruby = Erubis::Eruby.new(src)
      eruby.result(context)
    rescue Object => e
      raise Sprinkle::Errors::TemplateError.new(e, src, context)
    end
185023
function templateSelector(trumbowyg) {
        var available = trumbowyg.o.plugins.templates;
        var templates = [];

        $.each(available, function (index, template) {
            trumbowyg.addBtnDef('template_' + index, {
                fn: function () {
                    trumbowyg.html(template.html);
                },
                hasIcon: false,
                title: template.name
            });
            templates.push('template_' + index);
        });

        return templates;
    }
63441
private I_CmsFormWidget createTemplateSelector() {

        if (m_handler.useAdeTemplates()) {

            CmsSelectBox selectBox = null;
            Map<String, String> values = new LinkedHashMap<String, String>();
            for (Map.Entry<String, CmsClientTemplateBean> templateEntry : m_handler.getPossibleTemplates().entrySet()) {
                CmsClientTemplateBean template = templateEntry.getValue();
                String title = template.getTitle();
                if ((title == null) || (title.length() == 0)) {
                    title = template.getSitePath();
                }
                values.put(template.getSitePath(), title);
            }
            selectBox = new CmsPropertySelectBox(values);
            return selectBox;
        } else {
            CmsTextBox textbox = new CmsTextBox();
            return textbox;
        }
    }
173976
function (patternData, iframePassback, switchText) {

		Dispatcher.addListener('checkPanels', panelsViewer.checkPanels);

		// set-up defaults
		var template, templateCompiled, templateRendered, panel;

		// get the base panels
		var panels = Panels.get();

		// evaluate panels array and create content
		for (var i = 0; i < panels.length; ++i) {

			panel = panels[i];

			// catch pattern panel since it doesn't have a name defined by default
			if (panel.name === undefined) {
				panel.name = patternData.patternEngineName || patternData.patternExtension;
		        panel.language = patternData.patternExtension;
			}

			// if httpRequestReplace has not been set, use the extension. this is likely for the raw template
			if (panel.httpRequestReplace === '') {
				panel.httpRequestReplace = panel.httpRequestReplace + '.' + patternData.patternExtension;
			}

			if ((panel.templateID !== undefined) && (panel.templateID)) {

				if ((panel.httpRequest !== undefined) && (panel.httpRequest)) {

					// need a file and then render
					var fileBase = urlHandler.getFileName(patternData.patternPartial, false);
					var e = new XMLHttpRequest();
					e.onload = (function (i, panels, patternData, iframeRequest) {
						return function () {
							prismedContent = Prism.highlight(this.responseText, Prism.languages['html']);
							template = document.getElementById(panels[i].templateID);
							templateCompiled = Hogan.compile(template.innerHTML);
							templateRendered = templateCompiled.render({
								'language': 'html',
								'code': prismedContent
							});
							panels[i].content = templateRendered;
							Dispatcher.trigger('checkPanels', [panels, patternData, iframePassback, switchText]);
						};
					})(i, panels, patternData, iframePassback);

					e.open('GET', fileBase + panel.httpRequestReplace + '?' + (new Date()).getTime(), true);
					e.send();

				} else {

					// vanilla render of pattern data
					template = document.getElementById(panel.templateID);
					templateCompiled = Hogan.compile(template.innerHTML);
					templateRendered = templateCompiled.render(patternData);
					panels[i].content = templateRendered;
					Dispatcher.trigger('checkPanels', [panels, patternData, iframePassback, switchText]);

				}

			}

		}

	}
1333628
function view(template, options = {}) {

	if(!template) {
		throw new Exception('Please pass a template!');
	}

	return Class => {

		let renderedFlag = !(options.renderedFlag === false);

		initCoreMap(storage, Class);
		initViewMap(storage, Class);

		let map = storage.get(Class);

		/**
		 * Its required when we use @style multiple times!
		 * Only once registration!
		 */
		if(map.get('@view').get('callbacksDefined')){
			return;
		}

		map.get('@callbacks').get('created').push((domNode, createVars = {}) => {

			// get and merge dom view var attributes
			let domViewAttributes = extractDomProperties(
				domNode, /^@view\.bind\.(\S+)$/i, true
			);

			// get the restof regular attributes
			let regularDomAttributes = extractDomProperties(domNode);

			let viewBinds = {};
			let entries = map.get('@view').get('bind');
			entries.forEach(([key, value]) => viewBinds[key] = value);

			let viewVars = Object.assign({},
				viewBinds,
				domViewAttributes,
				createVars,
				regularDomAttributes
			);

			// initialize view
			let $view = new View({
				prerenderer: HandlebarsRuntime.template,
				rootNode: domNode,
				vars: viewVars,
				template: template,
			});

			view.helper.registerSetGet(
				domNode,
				Object.assign({}, viewBinds, domViewAttributes)
			);

			// render view
			$view.render(null, {
				renderedFlag: renderedFlag,
			});

			domNode.$view = $view;
		});

		map.get('@callbacks').get('attached').push(domNode => {

			if(domNode.$view.initialized()){
				return;
			}

			/**
			 * Using the same instance is 30% faster in
			 * (Chrome, Opera) and no difference in Firefox
			 * @see: https://jsperf.com/new-class-vs-singleton
			 */
			domNode.$view.reinit({
				rootNode: domNode,
				prerenderer: HandlebarsRuntime.template,
			});
		});

		map.get('@callbacks').get('detached').push(domNode => {
			domNode.$view.destroy();
		});

		map.get('@view').set('callbacksDefined', true);
	}
}
1279143
function docTemplate(page) {
    return page.doclayout ||
      (page.notemplate && 'none') ||
      (page.nolayout && page.template) ||
      (generator.template$['doc-layout'] && 'doc-layout') ||
      layoutTemplate(page);
  }
313853
private static String createRowTemplate(List<Integer> maxColumnSizes) {
    List<String> columnFormatSpecifiers = Lists.newArrayList();
    for (int maxColumnSize : maxColumnSizes) {
      columnFormatSpecifiers.add("%-" + maxColumnSize + "s");
    }
    return new StringBuilder("| ")
        .append(Joiner.on(" | ").join(columnFormatSpecifiers))
        .append(" |\n")
        .toString();
  }
72136
function createContentLeftMultiSelectRow(row, displayFlag) {
    var displayStr = '';
    if (!this.options.autoExpand && row.level > 0 && displayFlag != 'block') {
        displayStr = 'display:none;';
    }
    var tmpcheck = row.value["$_#_@_id"];
    if (!tmpcheck) {
        tmpcheck = setTimeout(function () {});
    }

    var rootObj = row.value;
    var objAry = this.selectRows;
    var re = objCompare(rootObj, objAry);
    var heightStr = '';

    if (!this.options.needResetHeight) {
        heightStr = 'height:' + (this.options.rowHeight + 1) + 'px;';
    }

    var createFlag = true;
    if (typeof this.options.onBeforeCreateLeftMul == 'function') {
        var obj = {
            gridObj: this,
            rowObj: row
        };
        createFlag = this.options.onBeforeCreateLeftMul.call(this, obj);
    }
    if (gridBrowser.isIE8) {
        //var	htmlStr = '<div style="width:' + this.multiSelectWidth + 'px;' + displayStr + '" class="u-grid-content-multiSelect " ><input class="u-grid-multi-input" id="checkbox'+tmpcheck+'" type="checkbox" value="1" ></div>'
        var htmlStr = '<div style="width:' + this.multiSelectWidth + 'px;' + heightStr + displayStr + '" class="u-grid-content-multiSelect " >';
        if (createFlag) htmlStr += '<span class="u-grid-checkbox-outline" id="checkbox' + tmpcheck + '" value="1"><span class="u-grid-checkbox-tick-outline"></span></span>';
        htmlStr += '</div>';
    } else {
        if (re) {
            var htmlStr = '<div style="width:' + this.multiSelectWidth + 'px;' + heightStr + displayStr + '" class="u-grid-content-multiSelect checkbox check-success u-grid-content-sel-row" >';
            if (createFlag) htmlStr += '<span class="u-grid-checkbox-outline  is-checked" id="checkbox' + tmpcheck + '" value="1"><span class="u-grid-checkbox-tick-outline"></span></span>';
            htmlStr += '</div>';
        } else {
            var htmlStr = '<div style="width:' + this.multiSelectWidth + 'px;' + heightStr + displayStr + '" class="u-grid-content-multiSelect checkbox check-success" >';
            if (createFlag) htmlStr += '<span class="u-grid-checkbox-outline" id="checkbox' + tmpcheck + '" value="1"><span class="u-grid-checkbox-tick-outline"></span></span>';
            htmlStr += '</div>';
        }
        //var htmlStr = '<div style="width:' + this.multiSelectWidth + 'px;' + displayStr + '" class="u-grid-content-multiSelect checkbox check-success" ><input class="u-grid-multi-input" id="checkbox'+tmpcheck+'" type="checkbox" value="1" ><label for="checkbox'+tmpcheck+'"></label></div>'
    }
    return htmlStr;
}
546883
public String buildSelectTemplates(String attributes) {

        List options = new ArrayList();
        List values = new ArrayList();
        TreeMap templates = null;
        int selectedIndex = -1;
        try {
            // get all available templates
            templates = CmsNewResourceXmlPage.getTemplates(getCms(), null);
        } catch (CmsException e) {
            // can usually be ignored
            if (LOG.isInfoEnabled()) {
                LOG.info(e);
            }
        }
        if (templates == null) {
            // no templates found, return empty String
            return "";
        } else {
            // templates found, create option and value lists
            CmsMessages messages = Messages.get().getBundle(getLocale());
            options.add(messages.key(Messages.GUI_PLEASE_SELECT_0));
            values.add("");
            options.add(messages.key(Messages.GUI_BUTTON_ALL_0));
            values.add(ALL);
            if (ALL.equals(getParamTemplate())) {
                selectedIndex = 1;
            }
            Iterator i = templates.entrySet().iterator();
            int counter = 2;
            while (i.hasNext()) {
                Map.Entry entry = (Map.Entry)i.next();
                String key = (String)entry.getKey();
                String path = (String)entry.getValue();
                if (path.equals(getParamTemplate())) {
                    selectedIndex = counter;
                }
                options.add(key);
                values.add(path);
                counter++;
            }
        }
        return buildSelect(attributes, options, values, selectedIndex, false);
    }
369306
def generate(template_name, object_binding)
      erb = ERB.new(File.read(File.join(template_path, template_name)), nil, "<>")
      erb.result(object_binding)
    end
65463
function(apiKey, templateId, pieceTitle,
        category, fromAddress, toAddress, ccAddress, bccAddresses, subject,
        textBody, htmlBody, contentType, mergeContext) {}
348704
public Template getTemplate(String name, Locale locale, Object args) throws IOException, ParseException {
        if (args instanceof String)
            return getTemplate(name, locale, (String) args);
        return getTemplate(name, locale, null, args);
    }