stream
The specific logic it let to the concrete subclasses
# Do the full rendering and write the final content to a stream
redef fun write_to(stream)
do
assert not is_writing
is_writing = true
force_render
for e in content do
e.write_to(stream)
end
is_writing = false
end
lib/template/template.nit:202,2--212,4
redef fun write_to(stream) do
stream.write "<"
stream.write tag
render_attrs_in(stream)
if is_void and (not isset _children or children.is_empty) then
stream.write "/>"
else
stream.write ">"
if isset _children then for child in children do child.write_to(stream)
stream.write "</"
stream.write tag
stream.write ">"
end
end
lib/html/html.nit:288,2--301,4
# print the full tree on `o`
# Write a ASCII-style tree and use the `display` method to label elements
redef fun write_to(stream: Writer)
do
for r in roots do
write_line(stream, r, "")
sub_write_to(stream, r, "")
end
end
lib/ordered_tree/ordered_tree.nit:145,2--153,4
# Write `self` to a `stream`
#
# Key with `null` values are ignored.
# The empty string can be used to represent an empty value.
#
# ~~~
# var ini = new IniFile
# ini["key"] = "value1"
# ini["key2"] = null
# ini["key3"] = ""
# ini["section1.key"] = "value2"
# ini["section1.key2"] = null
# ini["section2.key"] = "value3"
#
# var stream = new StringWriter
# ini.write_to(stream)
#
# assert stream.to_s == """
# key=value1
# key3=
# [section1]
# key=value2
# [section2]
# key=value3
# """
# ~~~
redef fun write_to(stream) do
for key, value in self do
if value == null then continue
stream.write "{key}={value}\n"
end
for section in sections do
stream.write "[{section.name}]\n"
for key, value in section do
if value == null then continue
stream.write "{key}={value}\n"
end
end
end
lib/ini/ini.nit:300,2--338,4