template :: TemplateString :: check
Return false if a macro was not replaced and store message in warnings
.
var tpl = new TemplateString("Hello %FIRSTNAME%, %LASTNAME%!")
assert not tpl.check
tpl.replace("FIRSTNAME", "Corben")
tpl.replace("LASTNAME", "Dallas")
assert tpl.check
# Check if all macros were replaced.
#
# Return false if a macro was not replaced and store message in `warnings`.
#
# var tpl = new TemplateString("Hello %FIRSTNAME%, %LASTNAME%!")
# assert not tpl.check
# tpl.replace("FIRSTNAME", "Corben")
# tpl.replace("LASTNAME", "Dallas")
# assert tpl.check
fun check: Bool do
warnings.clear
var all_ok = true
for name, macros in self.macros do
for macro in macros do
if not macro.is_replaced then
all_ok = false
warnings.add "No replacement for macro %{macro.name}% at {macro.location}"
end
end
end
return all_ok
end
lib/template/macro.nit:225,2--246,4