<commit_before>package de.rosebud.core;

import java.util.HashMap;
import java.util.Map;

import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;

public class ContentBuilder {
	// Generates the HTML out of the prepared tree
	public static String getContent(Fragment fragment) {
		// TODO: moeglichkeit bilden, dass kinderknoten daten dem
		// uebergeordneten Inhalt bereitstellen
		// Vielleicht zwei-pass anbieten?		
		
		StringBuilder start = new StringBuilder(TemplateRenderer.parseTemplate(
				fragment.getStartTemplate(), fragment.getData(), fragment));
		for (Fragment child : fragment.getChilds()) {
			start.append(ContentBuilder.getContent(child));
		}
		// End - Template
		Resource endTemplateResource = new ClassPathResource("/templates/"
				+ fragment.getStartTemplate() + "_end" + ".html");
		if (endTemplateResource.exists()) {
			start.append(TemplateRenderer.parseTemplate(fragment.getStartTemplate() + "_end",
					fragment.getData(), fragment));
		}
		return start.toString();
	}
	
	// Prepares the tree
	public static void contentLoad(Map<String, Object> globals, Fragment fragment) {
		fragment.collectData(globals);
		for (Fragment child : fragment.getChilds()) {
			ContentBuilder.contentLoad(globals, child);
		}
	}

}<commit_msg>Idea: call the "collectContent" method of fragments async.<commit_after>package de.rosebud.core;

import java.util.HashMap;
import java.util.Map;

import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;

public class ContentBuilder {
	// Generates the HTML out of the prepared tree
	public static String getContent(Fragment fragment) {
		// TODO: moeglichkeit bilden, dass kinderknoten daten dem
		// uebergeordneten Inhalt bereitstellen
		// Vielleicht zwei-pass anbieten?		
		
		StringBuilder start = new StringBuilder(TemplateRenderer.parseTemplate(
				fragment.getStartTemplate(), fragment.getData(), fragment));
		for (Fragment child : fragment.getChilds()) {
			start.append(ContentBuilder.getContent(child));
		}
		// End - Template
		Resource endTemplateResource = new ClassPathResource("/templates/"
				+ fragment.getStartTemplate() + "_end" + ".html");
		if (endTemplateResource.exists()) {
			start.append(TemplateRenderer.parseTemplate(fragment.getStartTemplate() + "_end",
					fragment.getData(), fragment));
		}
		return start.toString();
	}
	
	// Prepares the tree
	public static void contentLoad(Map<String, Object> globals, Fragment fragment) {
		// RFE: Do this async?
		fragment.collectData(globals);
		for (Fragment child : fragment.getChilds()) {
			ContentBuilder.contentLoad(globals, child);
		}
	}

}
{'fraction_non_alphanumeric': 0.11385767790262172, 'fraction_numerical': 0.0, 'mean_word_length': 4.682978723404255, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3011914', 'n_tokens_mistral': 835, 'n_tokens_neox': 765, 'n_words': 183}