TemplateString
.template :: TemplateMacro :: _replacement
Macro replacement if any.template :: TemplateMacro :: _start_pos
Macro starting position in template.template :: TemplateMacro :: defaultinit
template :: TemplateMacro :: end_pos=
Macro ending position in template.template :: TemplateMacro :: is_replaced
Doesself
already have a replacement
?
template :: TemplateMacro :: name=
Macro name as found in the template.template :: TemplateMacro :: replacement
Macro replacement if any.template :: TemplateMacro :: replacement=
Macro replacement if any.template :: TemplateMacro :: start_pos
Macro starting position in template.template :: TemplateMacro :: start_pos=
Macro starting position in template.template $ TemplateMacro :: SELF
Type of this instance, automatically specialized in every classtemplate :: Template :: _is_frozen
Is the template allowing more modification (add
)
template :: Template :: _is_writing
Flag to avoid infinite recursivity if a template contains itselftemplate :: Template :: _render_done
Flag to avoid multiple renderingtemplate :: TemplateMacro :: _replacement
Macro replacement if any.template :: TemplateMacro :: _start_pos
Macro starting position in template.core :: Object :: class_factory
Implementation used byget_class
to create the specific class.
template :: TemplateMacro :: defaultinit
core :: Object :: defaultinit
template :: Template :: defaultinit
core :: Writable :: defaultinit
template :: TemplateMacro :: end_pos=
Macro ending position in template.template :: Template :: is_frozen=
Is the template allowing more modification (add
)
template :: TemplateMacro :: is_replaced
Doesself
already have a replacement
?
core :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
template :: Template :: is_writing
Flag to avoid infinite recursivity if a template contains itselftemplate :: Template :: is_writing=
Flag to avoid infinite recursivity if a template contains itselftemplate :: TemplateMacro :: name=
Macro name as found in the template.core :: Object :: native_class_name
The class name of the object in CString format.core :: Object :: output_class_name
Display class name on stdout (debug only).template :: Template :: render_done=
Flag to avoid multiple renderingtemplate :: TemplateMacro :: replacement
Macro replacement if any.template :: TemplateMacro :: replacement=
Macro replacement if any.template :: TemplateMacro :: start_pos
Macro starting position in template.template :: TemplateMacro :: start_pos=
Macro starting position in template.core :: Writable :: write_to_bytes
Likewrite_to
but return a new Bytes (may be quite large)
core :: Writable :: write_to_file
Likewrite_to
but take care of creating the file
core :: Writable :: write_to_string
Likewrite_to
but return a new String (may be quite large).
# 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