template :: TemplateMacro :: defaultinit
# A macro is a special text command that is replaced by other content in a `TemplateString`.
private class TemplateMacro
super Template
# Macro name as found in the template.
var name: String
# Macro starting position in template.
var start_pos: Int
# Macro ending position in template.
var end_pos: Int
# Macro replacement if any.
var replacement: nullable Writable = null
# Does `self` already have a `replacement`?
fun is_replaced: Bool do return replacement != null
# Render `replacement` or else `name`.
redef fun rendering do
if is_replaced then
add replacement.as(not null)
else
add "%{name}%"
end
end
# Human readable location.
fun location: String do return "({start_pos}:{end_pos})"
end
lib/template/macro.nit:276,1--305,3