Translation.Return() Example

When translations reach a certain complexity, you can use translation.return() to immediately stop execution. This avoids having to use if or switch statements to prevent execution of other code below the current statement.

Translation.Return() immediately returns to the caller, with the given returnValue, or with the result previously set with translation.setresult().

Note that standard replacement output of the translation will not be used when using translation.return(). You must use translation.setresult(), translation.setnullresult(), or the returnValue argument of translation.return().

Smartsite SXML CopyCode image Copy Code
<se:pagetranslations id="helpers">
    <se:collection>
        <se:member name="test()">
            Hello!
            {translation.return(1)}
            {sys.throwexception(ApplicationError, "Unreachable code!")}
        </se:member>
    </se:collection>
</se:pagetranslations>

{translation.helpers.test()}
Example Result CopyCode image Copy Code
1