Accessing resources at compile time with generated Perl code

You can access resources at compile time with generated Perl code.

Procedure

To access the resource, add a require directive for the Perl module.

Example

<%SPL::CodeGen::implementationPrologue($model);%>
<%
require MyResource;

# // Emit the formatted string to standard out
SPL::CodeGen::println(MyResource::MY_TOOLKIT_MESSAGE_1("MyOperator"));
%>

In this example, you are writing a cgt file for an operator and want to write a locale-sensitive string to the console at compile time. Use the require directive for a module MyResource.pm. The MY_TOOLKIT_MESSAGE_1 subroutine is called to get the formatted string and the helper routine println is called to write the string to the console.