Show TOC

aliasLocate this document in the navigation structure

The <template:alias> instruction can be used to define a shortcut alias name for a JavaScript value, for example a static helper class, a formatter function, or a helper function.

The shortcut alias is only available in the scope of the alias instruction. Each nested scope can redefine aliases. The shortcut name must start with a dot to remind you how it is used in data binding expression, for example, when referring to a formatter function, or in a <template:with helper=".aliasName"> statement.

A proper relative name must be used. This proper name must not contain or consist of a dot. The value to which the alias refers to can be any JavaScript object or property including a function that is available at that point. Exisiting alias names can be used in new alias definitions to refer to values, for example, <template:alias name=".format" value=".AH.format">. Aliases are inherited into fragments, but of course a fragment may (re)define its own set of aliases.


"alias" Template
<template:alias name=".AH" value="sap.ui.model.odata.AnnotationHelper">
  <template:with path="meta>" var="badge">
        <core:Title text="{path: 'badge>HeadLine', formatter: '.AH.format'}"/>
      <Label text="{path: 'badge>Title/Label', formatter: '.AH.format'}"/>
      <Text text="{path: 'badge>Title/Value', formatter: '.AH.format'}"/>
      <Label text="{path: 'badge>MainInfo/Label', formatter: '.AH.format'}"/>
      <template:with path="badge>MainInfo" var="field">
        <core:Fragment fragmentName="sap.ui.core.sample.ViewTemplate.tiny.Field" type="XML"/>
      <Label text="{path: 'badge>SecondaryInfo/Label', formatter: '.AH.format'}"/>
      <template:with path="badge>SecondaryInfo" var="field">
        <core:Fragment fragmentName="sap.ui.core.sample.ViewTemplate.tiny.Field" type="XML"/>