Fix template function.

Take string values with text-properties into account.
Remove trailing trash-code.
Fix iorg-data template.