Improved template compiler's doPageSwitcher.

The variable format replacing will be handle more carefully.