Replace PROJECTNAME_LOWER before PROJECTNAME
Replace PROJECTNAME_LOWER before PROJECTNAME

(If you replace "PROJECTNAME" first, then what remains is <replacement>_LOWER, which isn't matched by the replace for "PROJECTNAME_LOWER")

yesodweb/yesod-scaffold