Welcome, Guest Login

Support Center

Custom Expanders

Last Updated: Oct 14, 2015 05:39PM EDT

Custom expanders are much less common than custom formatters, but their API is simpler, so we will cover them first.

Each expander is implemented as a static method, where the name of the expander is the name of the method. The method takes one string argument (the input text) and returns a string value (the expanded text).

EachScape provides a default “text” expander that simply returns the text unchanged, allowing formatters to be applied to literal strings. The following examples show how the same functionality could be implemented as a custom expander named “identity”.

For iOS, you must implement a category on the class ESTemplateExpander.

#import "ESTemplateExpander.h"

@implementation ESTemplateExpander (ESCustomHooks)

+ (NSString *)identity:(NSString *)text {
  return text;


For Android, you must implement an inner class TemplateExpander within the class ESCustomHooks.

package com.eachscape.models.other.scripts;

public final class ESCustomHooks
  public final static class TemplateExpander
    public static final String identity(String text) {
      return text;

Note that in both cases, the name of the static method is the name of the expander. With this custom expander implemented, this template:


would return the string “fred”.

Help us improve! Rate this article:

Yes I found this article helpful

Ask a Question   

seconds ago
a minute ago
minutes ago
an hour ago
hours ago
a day ago
days ago
Invalid characters found