<commit_before>package org.wso2.carbon.uuf.core;

import com.github.jknack.handlebars.Context;
import com.github.jknack.handlebars.Template;
import com.github.jknack.handlebars.io.TemplateSource;
import org.wso2.carbon.uuf.core.util.InitHandlebarsUtil;
import org.wso2.carbon.uuf.core.util.RuntimeHandlebarsUtil;

import javax.annotation.Nullable;
import java.io.IOException;
import java.util.Collections;
import java.util.Map;


public class HandlebarsRenderble implements Renderble {

    private final Template template;
    private final Map<String, Renderble> fillingZones;
    @Nullable
    private final String layoutName;


    public HandlebarsRenderble(TemplateSource source) {
        this.template = RuntimeHandlebarsUtil.compile(source);

        Context context = Context.newContext(Collections.EMPTY_MAP);
        try {
            Template preTemplate = InitHandlebarsUtil.compile(source);
            preTemplate.apply(context);
        } catch (IOException e) {
            throw new UUFException("pages template completions error", e);
        }
        this.layoutName = InitHandlebarsUtil.getLayoutName(context);
        this.fillingZones = InitHandlebarsUtil.getFillingZones(context);
    }


    @Override
    public String render(Object o, Map<String, Renderble> zones, Map<String, Renderble> fragments) {
        Context context = Context.newContext(o);
        RuntimeHandlebarsUtil.setZones(context, zones);
        RuntimeHandlebarsUtil.setFragment(context, fragments);
        try {
            return template.apply(context);
        } catch (IOException e) {
            throw new UUFException("Handlebars rendering failed", e);
        }
    }

    @Override
    public Map<String, Renderble> getFillingZones() {
        return fillingZones;
    }

    @Override
    public String toString() {
        return "{path:'" + template.filename() + "'}";
    }

    @Override
    @Nullable
    public String getLayoutName() {
        return layoutName;
    }
}<commit_msg>fix file name not visible bug<commit_after>package org.wso2.carbon.uuf.core;

import com.github.jknack.handlebars.Context;
import com.github.jknack.handlebars.Template;
import com.github.jknack.handlebars.io.TemplateSource;
import org.wso2.carbon.uuf.core.util.InitHandlebarsUtil;
import org.wso2.carbon.uuf.core.util.RuntimeHandlebarsUtil;

import javax.annotation.Nullable;
import java.io.IOException;
import java.util.Collections;
import java.util.Map;


public class HandlebarsRenderble implements Renderble {

    private final Template template;
    private final Map<String, Renderble> fillingZones;
    @Nullable
    private final String layoutName;
    private final String name;


    public HandlebarsRenderble(TemplateSource source) {
        this.template = RuntimeHandlebarsUtil.compile(source);
        // We have to separately remember this since there is a bug in Handlebar lib's
        // filename() method when the file is empty or stats with a comment
        this.name = source.filename();

        Context context = Context.newContext(Collections.EMPTY_MAP);
        try {
            Template preTemplate = InitHandlebarsUtil.compile(source);
            preTemplate.apply(context);
        } catch (IOException e) {
            throw new UUFException("pages template completions error", e);
        }
        this.layoutName = InitHandlebarsUtil.getLayoutName(context);
        this.fillingZones = InitHandlebarsUtil.getFillingZones(context);
    }


    @Override
    public String render(Object o, Map<String, Renderble> zones, Map<String, Renderble> fragments) {
        Context context = Context.newContext(o);
        RuntimeHandlebarsUtil.setZones(context, zones);
        RuntimeHandlebarsUtil.setFragment(context, fragments);
        try {
            return template.apply(context);
        } catch (IOException e) {
            throw new UUFException("Handlebars rendering failed", e);
        }
    }

    @Override
    public Map<String, Renderble> getFillingZones() {
        return fillingZones;
    }

    @Override
    public String toString() {
        return "{path:'" + name + "'}";
    }

    @Override
    @Nullable
    public String getLayoutName() {
        return layoutName;
    }
}
{'fraction_non_alphanumeric': 0.09148936170212765, 'fraction_numerical': 0.0014184397163120568, 'mean_word_length': 3.139921722113503, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '2369145', 'n_tokens_mistral': 1170, 'n_tokens_neox': 1153, 'n_words': 271}