<commit_before>package beluga.core;
import beluga.core.macro.ConfigLoader;
import haxe.Resource;
import sys.io.File;

/**
 * ...
 * @author Masadow
 */
class Widget
{
	private static var last_id : Int;
	private static var available_resources = Resource.listNames();

	public var context : Dynamic;
	private var filecontent : String;
	private var id : Int;
	private var html : String;
	
	private var css : String;

	public function new(module : Null<String>, name : Null<String>)
	{
		if (module != null && name != null) {

			//Load template
			if (Lambda.has(available_resources, "beluga_" + module + "_" + name)) {
				filecontent = Resource.getString("beluga_" + module + "_" + name);
			} else {
				throw new BelugaException("The widget " + name + " does not exists");
			}
			
			if (Lambda.has(available_resources, "beluga_" + module + "_css_" + name)) {
				css = Resource.getString("beluga_" + module + "_css_" + name);
			} else {
				//No Css file provide put log warning
			}
				
		}
		context = { };
		id = 0;
		html = "";
	}
	
	//Once a widget is rendered, you can't modify it again.
	//If you want to this, you have to clone it (before or after first rendering)
	public function render() : String {
		if (id == 0) {
			var t = new haxe.Template(filecontent);
			context._id = ++last_id;
			id = context.id;
			if (ConfigLoader.config.hasNode.url && ConfigLoader.config.node.url.hasNode.base && ConfigLoader.config.node.url.node.base.hasNode.innerData)
				context.base_url = ConfigLoader.config.node.url.node.base.innerData;
			html = t.execute(context);
		}
		return html;
	}
	
	public function getId() : Int {
		return id;
	}

	public function clone() : Widget {
		var ret = new Widget(null, null);
		ret.filecontent = filecontent;
		ret.context = context;
		return ret;
	}
	<commit_msg>Fix condition<commit_after>package beluga.core;
import beluga.core.macro.ConfigLoader;
import haxe.Resource;
import sys.io.File;

/**
 * ...
 * @author Masadow
 */
class Widget
{
	private static var last_id : Int;
	private static var available_resources = Resource.listNames();

	public var context : Dynamic;
	private var filecontent : String;
	private var id : Int;
	private var html : String;
	
	private var css : String;

	public function new(module : Null<String>, name : Null<String>)
	{
		if (module != null && name != null) {

			//Load template
			if (Lambda.has(available_resources, "beluga_" + module + "_" + name)) {
				filecontent = Resource.getString("beluga_" + module + "_" + name);
			} else {
				throw new BelugaException("The widget " + name + " does not exists");
			}
			
			if (Lambda.has(available_resources, "beluga_" + module + "_css_" + name)) {
				css = Resource.getString("beluga_" + module + "_css_" + name);
			} else {
				//No Css file provide put log warning
			}
				
		}
		context = { };
		id = 0;
		html = "";
	}
	
	//Once a widget is rendered, you can't modify it again.
	//If you want to this, you have to clone it (before or after first rendering)
	public function render() : String {
		if (id == 0) {
			var t = new haxe.Template(filecontent);
			context._id = ++last_id;
			id = context.id;
			if (ConfigLoader.config.hasNode.url && ConfigLoader.config.node.url.hasNode.base)
				context.base_url = ConfigLoader.config.node.url.node.base.innerData;
			html = t.execute(context);
		}
		return html;
	}
	
	public function getId() : Int {
		return id;
	}

	public function clone() : Widget {
		var ret = new Widget(null, null);
		ret.filecontent = filecontent;
		ret.context = context;
		return ret;
	}
	
{'fraction_non_alphanumeric': 0.13154929577464788, 'fraction_numerical': 0.0011267605633802818, 'mean_word_length': 3.232419547079857, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '1962164', 'n_tokens_mistral': 1295, 'n_tokens_neox': 1135, 'n_words': 334}