code: private void _serialize(Writer writer, Object model) throws IOException
    {
      if(model == null) {
        document.serialize(writer);
        return;
      }
  
      Serializer serializer = new Serializer();
      if(serializeOperators) {
        serializer.enableOperatorsSerialization();
      }
  
      Content content = model instanceof Content ? (Content)model : new Content(model);
      serializer.setContent(content);
      serializer.setWriter(writer);
  
      if(serializeProlog) {
        if(document.isXML()) {
          serializer.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n");
        }
        else {
          // if is not XML document should be HTML5
          serializer.write("<!DOCTYPE HTML>\r\n");
        }
      }
      if(document.getRoot() != null) {
        serializer.write(document.getRoot(), content.getModel());
      }
      serializer.flush();
    }
docs: Serialize template with given domain model to a writer. Walk through template document from its root and serialize
  every node; if node contains operators execute them. Operators extract values from given domain model and process
  them, result going to the same writer.
  <p>
  Writer parameter does not need to be {@link BufferedWriter}, but is acceptable. This interface implementation takes
  care to initialize the writer accordingly. Given domain model can be an instance of {@link Content} or any POJO
  containing values needed by template operators.
  <p>
  If any argument is null or writer is already closed this method behavior is not defined.
  <p>
  This method creates and instance of {@link Serializer} then delegates
  {@link Serializer#write(js.dom.Element, Object)} for actual work.
  
  @param model domain model object to inject into template,
  @param writer writer to serialize template to.