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

import com.github.jknack.handlebars.Context;
import com.github.jknack.handlebars.Handlebars;
import com.github.jknack.handlebars.Template;
import com.github.jknack.handlebars.io.TemplateSource;
import org.wso2.carbon.uuf.core.UUFException;
import org.wso2.carbon.uuf.handlebars.helpers.init.FillZoneHelper;
import org.wso2.carbon.uuf.handlebars.helpers.init.LayoutHelper;
import org.wso2.carbon.uuf.handlebars.helpers.runtime.ResourceHelper;

import java.io.IOException;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;

public class HbsPageRenderable extends HbsRenderable {
    private final Map<String, HbsPageRenderable> fillingZone;
    private final List<String> headJs;
    private final Optional<String> layout;

    private static final Handlebars HANDLEBARS = new Handlebars();

    static {
        HANDLEBARS.registerHelper("fillZone", FillZoneHelper.getInstance());
        HANDLEBARS.registerHelper("layout", LayoutHelper.getInstance());
        HANDLEBARS.registerHelper("headJs", ResourceHelper.JS_INSTANCE);
        HANDLEBARS.registerHelperMissing((context, options) -> "");
    }
    
    public HbsPageRenderable(TemplateSource template, Optional<Executable> executable) {
        super(template, executable);
        Template compiledTemplate;
        Context context = Context.newContext(Collections.EMPTY_MAP);
        try {
            compiledTemplate = HANDLEBARS.compile(template);
            compiledTemplate.apply(context);
        } catch (IOException e) {
            throw new UUFException("pages template completions error", e);
        }
        Map<String, HbsPageRenderable> zones = context.data(FillZoneHelper.ZONES_KEY);
        fillingZone = (zones == null) ? Collections.emptyMap() : zones;
        layout = Optional.ofNullable(context.data(LayoutHelper.LAYOUT_KEY));
        List<String> headJsList = context.data(ResourceHelper.JS_INSTANCE.getResourceKey());
        headJs = (headJsList == null) ? Collections.emptyList() : headJsList;
    }

    public List<String> getHeadJs() {
        return headJs;
    }
<commit_msg>using 'ResourceHelper.getHeaderJsInstance()' to get an instance of 'headerJs' Handlebars helper<commit_after>package org.wso2.carbon.uuf.handlebars;

import com.github.jknack.handlebars.Context;
import com.github.jknack.handlebars.Handlebars;
import com.github.jknack.handlebars.Template;
import com.github.jknack.handlebars.io.TemplateSource;
import org.wso2.carbon.uuf.core.UUFException;
import org.wso2.carbon.uuf.handlebars.helpers.init.FillZoneHelper;
import org.wso2.carbon.uuf.handlebars.helpers.init.LayoutHelper;
import org.wso2.carbon.uuf.handlebars.helpers.runtime.ResourceHelper;

import java.io.IOException;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;

public class HbsPageRenderable extends HbsRenderable {
    private final Map<String, HbsPageRenderable> fillingZone;
    private final List<String> headJs;
    private final Optional<String> layout;

    private static final Handlebars HANDLEBARS = new Handlebars();

    static {
        HANDLEBARS.registerHelper("fillZone", FillZoneHelper.getInstance());
        HANDLEBARS.registerHelper("layout", LayoutHelper.getInstance());
        HANDLEBARS.registerHelper("headerJs", ResourceHelper.getHeaderJsInstance());
        HANDLEBARS.registerHelperMissing((context, options) -> "");
    }
    
    public HbsPageRenderable(TemplateSource template, Optional<Executable> executable) {
        super(template, executable);
        Template compiledTemplate;
        Context context = Context.newContext(Collections.EMPTY_MAP);
        try {
            compiledTemplate = HANDLEBARS.compile(template);
            compiledTemplate.apply(context);
        } catch (IOException e) {
            throw new UUFException("pages template completions error", e);
        }
        Map<String, HbsPageRenderable> zones = context.data(FillZoneHelper.ZONES_KEY);
        fillingZone = (zones == null) ? Collections.emptyMap() : zones;
        layout = Optional.ofNullable(context.data(LayoutHelper.LAYOUT_KEY));
        List<String> headJsList = context.data(ResourceHelper.getHeaderJsInstance().getResourceKey());
        headJs = (headJsList == null) ? Collections.emptyList() : headJsList;
    }

    public List<String> getHeadJs() {
        return headJs;
    }

{'fraction_non_alphanumeric': 0.1044005388414908, 'fraction_numerical': 0.00224517287831163, 'mean_word_length': 4.07981755986317, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 19, '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': '1466497', 'n_tokens_mistral': 1307, 'n_tokens_neox': 1264, 'n_words': 233}