Configuring Block Editor Label Properties

When configuring a block, the label property allows you to define a label for the appearance of the Block in the editor. The label can use AngularJS template string syntax to display values of properties. Example: My Block {{myPropertyAlias}} will be shown as: My Block FooBar.

You can also use more advanced expressions using AngularJS filters. Example: {{myPropertyAlias | limitTo:100}} or for a property using Richtext editor {{myPropertyAlias | ncRichText | truncate:true:100}}.

It is also possible to use properties from the settings model by using {{$settings.propertyAlias}}.

Useful Angular filters

As well as the default AngularJS filters, Umbraco ships with some additional filters which are useful for setting the Label field of Block editors.

Custom filters

If the filters do not suit your needs, you can create custom filters by creating a plugin in App_Plugins and adding a filter module. You can see an example below:

If you do not have an /App_Plugins folder, you can create it at the root of your project.

  1. Create a plugin by adding a folder inside App_Plugins called MyFilters

  2. Inside the MyFilters folder add a package.manifest file containing:

{
    "name": "MyFilters",
    "version": "1.0.0",
    "allowPackageTelemetry": false,
    "javascript": [
        "/App_Plugins/MyFilters/myFilter.filter.js"
    ]
}
  1. Add a myFilter.filter.js file containing:

angular.module("umbraco.filters").filter("myFilter", function () {
  return function (input, parameter1, parameter2, etc) {
      // Apply any custom logic to modify the output value and return a string
      return `My filter says: "${input}"`;
  }
});
  1. Implement a block editor of your choice. When adding a label add {{ myFilter }} which is the property alias of the element type. The myFilter property has a textstring editor. When adding the content, the block editor will then display the data that you input.

Special variables

Last updated