pascal.ijs: encapsulate state machine details in Template