frontend js logic, parse then templates