All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.beothorn.html.common.Render Maven / Gradle / Ivy

There is a newer version: 0.0.7
Show newest version
package com.github.beothorn.html.common;

import java.util.List;
import java.util.stream.Collectors;

import com.github.beothorn.html.Renderable;

public class Render {
	
	public static String renderTag(
		final String tag, 
		final List children
	){
		StringBuilder rendered = new StringBuilder();
		rendered.append("<" + tag + ">");
		children.stream()
			.map(Renderable::render)
			.forEach(rendered::append);
		rendered.append("");
		return rendered.toString();
	}
	
	public static String renderTag(
		final String tag,
		final List props,
		final List children
	){
		StringBuilder rendered = new StringBuilder();
		rendered.append("<"+tag+" ");
		rendered.append(props.stream()
			.map(Renderable::render)
			.collect(Collectors.joining(" "))
		);
		if(props.size() > 0)
		rendered.append(">");
		children.stream()
			.map(Renderable::render)
			.forEach(rendered::append);
		rendered.append("");
		return rendered.toString();
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy