// Path: src/main/java/com/adeptj/runtime/common/Times.java
// public final class Times {
// 
//     // No instances, just utility methods.
//     private Times() {
//     }
// 
//     /**
//      * Returns elapsed time in milliseconds from the provided time in nanoseconds.
//      *
//      * @param startTime time in nanoseconds
//      * @return elapsed time in milliseconds
//      */
//     public static long elapsedMillis(final long startTime) {
//         return NANOSECONDS.toMillis(System.nanoTime() - startTime);
//     }
// 
//     /**
//      * Returns elapsed time in seconds from the provided time in milliseconds.
//      *
//      * @param startTime time in milliseconds
//      * @return elapsed time in seconds
//      */
//     public static long elapsedSeconds(final long startTime) {
//         return MILLISECONDS.toSeconds(System.currentTimeMillis() - startTime);
//     }
// }
// 
// Path: src/main/java/com/adeptj/runtime/config/Configs.java
// public enum Configs {
// 
//     INSTANCE;
// 
//     /**
//      * This will include system properties as well.
//      */
//     private final Config root;
// 
//     Configs() {
//         this.root = this.loadConf();
//     }
// 
//     public Config root() {
//         return this.root;
//     }
// 
//     public Config main() {
//         return this.root.getConfig(MAIN_CONF_SECTION);
//     }
// 
//     public Config undertow() {
//         return this.main().getConfig(UNDERTOW_CONF_SECTION);
//     }
// 
//     public Config felix() {
//         return this.main().getConfig(FELIX_CONF_SECTION);
//     }
// 
//     public Config common() {
//         return this.main().getConfig(COMMON_CONF_SECTION);
//     }
// 
//     public Config logging() {
//         return this.main().getConfig(LOGGING_CONF_SECTION);
//     }
// 
//     public Config trimou() {
//         return this.main().getConfig(TRIMOU_CONF_SECTION);
//     }
// 
//     public Config resteasy() {
//         return this.main().getConfig(RESTEASY_CONF_SECTION);
//     }
// 
//     private Config loadConf() {
//         Config config;
//         File configFile = Environment.getServerConfPath().toFile();
//         if (configFile.exists()) {
//             // if overwrite.server.conf.file system property is provided, then load the configs from classpath.
//             if (Boolean.getBoolean(SYS_PROP_OVERWRITE_SERVER_CONF)) {
//                 config = ConfigFactory.load(SERVER_CONF_FILE);
//             } else {
//                 config = ConfigFactory.parseFile(configFile)
//                         .withFallback(ConfigFactory.systemProperties())
//                         .resolve();
//             }
//         } else {
//             config = ConfigFactory.load(SERVER_CONF_FILE);
//         }
//         return config;
//     }
// 
//     public static Configs of() {
//         return INSTANCE;
//     }
// 
// }
// 
// Path: src/main/java/com/adeptj/runtime/common/Constants.java
// public static final String CONTENT_TYPE_HTML_UTF8 = "text/html;charset=UTF-8";
// 
// Path: src/main/java/com/adeptj/runtime/common/Constants.java
// public static final String UTF8 = "UTF-8";


import static com.adeptj.runtime.common.Constants.CONTENT_TYPE_HTML_UTF8;
import static com.adeptj.runtime.common.Constants.UTF8;
import static org.trimou.engine.config.EngineConfigurationKey.DEFAULT_FILE_ENCODING;
import static org.trimou.engine.config.EngineConfigurationKey.END_DELIMITER;
import static org.trimou.engine.config.EngineConfigurationKey.START_DELIMITER;
import static org.trimou.engine.config.EngineConfigurationKey.TEMPLATE_CACHE_ENABLED;
import static org.trimou.engine.config.EngineConfigurationKey.TEMPLATE_CACHE_EXPIRATION_TIMEOUT;
import static org.trimou.handlebars.i18n.ResourceBundleHelper.Format.MESSAGE;
import com.adeptj.runtime.common.Times;
import com.adeptj.runtime.config.Configs;
import com.typesafe.config.Config;
import org.slf4j.LoggerFactory;
import org.trimou.Mustache;
import org.trimou.engine.MustacheEngine;
import org.trimou.engine.MustacheEngineBuilder;
import org.trimou.engine.locator.ClassPathTemplateLocator;
import org.trimou.handlebars.i18n.ResourceBundleHelper;

    TemplateEngine() {
        long startTime = System.nanoTime();
        Config config = Configs.of().trimou();
        this.mustacheEngine = MustacheEngineBuilder.newBuilder()
                .registerHelper(RB_HELPER_NAME, new ResourceBundleHelper(config.getString(KEY_RB_BASE_NAME), MESSAGE))
                .addTemplateLocator(ClassPathTemplateLocator.builder()
                        .setPriority(config.getInt(KEY_TEMPLATE_LOCATOR_PRIORITY))
                        .setRootPath(config.getString(KEY_PREFIX))
                        .setSuffix(config.getString(KEY_SUFFIX))
                        .setScanClasspath(false)
                        .build())
                .setProperty(START_DELIMITER, config.getString(KEY_START_DELIMITER))
                .setProperty(END_DELIMITER, config.getString(KEY_END_DELIMITER))
                .setProperty(DEFAULT_FILE_ENCODING, UTF8)
                .setProperty(TEMPLATE_CACHE_ENABLED, config.getBoolean(KEY_CACHE_ENABLED))
                .setProperty(TEMPLATE_CACHE_EXPIRATION_TIMEOUT, config.getInt(KEY_CACHE_EXPIRATION))
                .build();
        LoggerFactory.getLogger(this.getClass()).info(TEMPLATE_ENGINE_INIT_MSG, Times.elapsedMillis(startTime));
    }

    /**
     * Renders the template contained by the {@link TemplateEngineContext#getTemplate()}
     *
     * @param context the TemplateEngine context
     * @throws TemplateProcessingException if there was some issue while rendering the template.
     */
    public void render(TemplateEngineContext context) {
        try {
            // Making sure the Content-Type will always be text/html;charset=UTF-8.
// Path: src/main/java/com/adeptj/runtime/common/Times.java
// public final class Times {
// 
//     // No instances, just utility methods.
//     private Times() {
//     }
// 
//     /**
//      * Returns elapsed time in milliseconds from the provided time in nanoseconds.
//      *
//      * @param startTime time in nanoseconds
//      * @return elapsed time in milliseconds
//      */
//     public static long elapsedMillis(final long startTime) {
//         return NANOSECONDS.toMillis(System.nanoTime() - startTime);
//     }
// 
//     /**
//      * Returns elapsed time in seconds from the provided time in milliseconds.
//      *
//      * @param startTime time in milliseconds
//      * @return elapsed time in seconds
//      */
//     public static long elapsedSeconds(final long startTime) {
//         return MILLISECONDS.toSeconds(System.currentTimeMillis() - startTime);
//     }
// }
// 
// Path: src/main/java/com/adeptj/runtime/config/Configs.java
// public enum Configs {
// 
//     INSTANCE;
// 
//     /**
//      * This will include system properties as well.
//      */
//     private final Config root;
// 
//     Configs() {
//         this.root = this.loadConf();
//     }
// 
//     public Config root() {
//         return this.root;
//     }
// 
//     public Config main() {
//         return this.root.getConfig(MAIN_CONF_SECTION);
//     }
// 
//     public Config undertow() {
//         return this.main().getConfig(UNDERTOW_CONF_SECTION);
//     }
// 
//     public Config felix() {
//         return this.main().getConfig(FELIX_CONF_SECTION);
//     }
// 
//     public Config common() {
//         return this.main().getConfig(COMMON_CONF_SECTION);
//     }
// 
//     public Config logging() {
//         return this.main().getConfig(LOGGING_CONF_SECTION);
//     }
// 
//     public Config trimou() {
//         return this.main().getConfig(TRIMOU_CONF_SECTION);
//     }
// 
//     public Config resteasy() {
//         return this.main().getConfig(RESTEASY_CONF_SECTION);
//     }
// 
//     private Config loadConf() {
//         Config config;
//         File configFile = Environment.getServerConfPath().toFile();
//         if (configFile.exists()) {
//             // if overwrite.server.conf.file system property is provided, then load the configs from classpath.
//             if (Boolean.getBoolean(SYS_PROP_OVERWRITE_SERVER_CONF)) {
//                 config = ConfigFactory.load(SERVER_CONF_FILE);
//             } else {
//                 config = ConfigFactory.parseFile(configFile)
//                         .withFallback(ConfigFactory.systemProperties())
//                         .resolve();
//             }
//         } else {
//             config = ConfigFactory.load(SERVER_CONF_FILE);
//         }
//         return config;
//     }
// 
//     public static Configs of() {
//         return INSTANCE;
//     }
// 
// }
// 
// Path: src/main/java/com/adeptj/runtime/common/Constants.java
// public static final String CONTENT_TYPE_HTML_UTF8 = "text/html;charset=UTF-8";
// 
// Path: src/main/java/com/adeptj/runtime/common/Constants.java
// public static final String UTF8 = "UTF-8";


// Path: src/main/java/com/adeptj/runtime/htmlrender/TemplateEngine.java
import static com.adeptj.runtime.common.Constants.CONTENT_TYPE_HTML_UTF8;
import static com.adeptj.runtime.common.Constants.UTF8;
import static org.trimou.engine.config.EngineConfigurationKey.DEFAULT_FILE_ENCODING;
import static org.trimou.engine.config.EngineConfigurationKey.END_DELIMITER;
import static org.trimou.engine.config.EngineConfigurationKey.START_DELIMITER;
import static org.trimou.engine.config.EngineConfigurationKey.TEMPLATE_CACHE_ENABLED;
import static org.trimou.engine.config.EngineConfigurationKey.TEMPLATE_CACHE_EXPIRATION_TIMEOUT;
import static org.trimou.handlebars.i18n.ResourceBundleHelper.Format.MESSAGE;
import com.adeptj.runtime.common.Times;
import com.adeptj.runtime.config.Configs;
import com.typesafe.config.Config;
import org.slf4j.LoggerFactory;
import org.trimou.Mustache;
import org.trimou.engine.MustacheEngine;
import org.trimou.engine.MustacheEngineBuilder;
import org.trimou.engine.locator.ClassPathTemplateLocator;
import org.trimou.handlebars.i18n.ResourceBundleHelper;


    TemplateEngine() {
        long startTime = System.nanoTime();
        Config config = Configs.of().trimou();
        this.mustacheEngine = MustacheEngineBuilder.newBuilder()
                .registerHelper(RB_HELPER_NAME, new ResourceBundleHelper(config.getString(KEY_RB_BASE_NAME), MESSAGE))
                .addTemplateLocator(ClassPathTemplateLocator.builder()
                        .setPriority(config.getInt(KEY_TEMPLATE_LOCATOR_PRIORITY))
                        .setRootPath(config.getString(KEY_PREFIX))
                        .setSuffix(config.getString(KEY_SUFFIX))
                        .setScanClasspath(false)
                        .build())
                .setProperty(START_DELIMITER, config.getString(KEY_START_DELIMITER))
                .setProperty(END_DELIMITER, config.getString(KEY_END_DELIMITER))
                .setProperty(DEFAULT_FILE_ENCODING, UTF8)
                .setProperty(TEMPLATE_CACHE_ENABLED, config.getBoolean(KEY_CACHE_ENABLED))
                .setProperty(TEMPLATE_CACHE_EXPIRATION_TIMEOUT, config.getInt(KEY_CACHE_EXPIRATION))
                .build();
        LoggerFactory.getLogger(this.getClass()).info(TEMPLATE_ENGINE_INIT_MSG, Times.elapsedMillis(startTime));
    }

    /**
     * Renders the template contained by the {@link TemplateEngineContext#getTemplate()}
     *
     * @param context the TemplateEngine context
     * @throws TemplateProcessingException if there was some issue while rendering the template.
     */
    public void render(TemplateEngineContext context) {
        try {
            // Making sure the Content-Type will always be text/html;charset=UTF-8.
            context.getResponse().setContentType(CONTENT_TYPE_HTML_UTF8);