Write itself to a stream

The specific logic it let to the concrete subclasses

Property definitions

core $ Writable :: write_to
	# Write itself to a `stream`
	# The specific logic it let to the concrete subclasses
	fun write_to(stream: Writer) is abstract
lib/core/stream.nit:554,2--556,41

template $ Template :: write_to
	# 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

html $ HTMLPage :: write_to
	redef fun write_to(stream) do
		root.children.clear
		open("head")
		head
		close("head")
		open("body")
		body
		close("body")
		stream.write "<!DOCTYPE html>"
		root.write_to(stream)
	end
lib/html/html.nit:46,2--56,4

html $ HTMLTag :: write_to
	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

csv $ CsvDocument :: write_to
	redef fun write_to(stream) do
		var s = new CsvWriter(stream)
		s.separator = separator
		s.eol = eol
		s.delimiter = delimiter
		if not header.is_empty then
			s.write_line header
		end
		s.write_lines(records)
	end
lib/csv/csv.nit:138,2--147,4

html $ HTMLRaw :: write_to
	redef fun write_to(stream) do stream.write content
lib/html/html.nit:352,2--51

ordered_tree $ OrderedTree :: write_to
	# 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

ini $ IniFile :: write_to
	# 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

core :: stream $ Text :: write_to
	redef fun write_to(stream) do stream.write(self)
lib/core/stream.nit:595,2--49

core :: stream $ Bytes :: write_to
	redef fun write_to(s) do s.write_bytes(self)
lib/core/stream.nit:588,2--45