Package org.rythmengine

Examples of org.rythmengine.RythmEngine


       Map<String, Object> config = new HashMap<String, Object>();
       config.put("engine.mode", "dev");
       config.put("home.template.dir", "p:/jfinal-rythm-demo/WebRoot/css");
       final RythmEngine engine = new RythmEngine(config);
       WL("Prod Mode:" + engine.isProdMode());
       WL(engine.render("my.html", "brian N"));
       //engine.shutdown();
    }
View Full Code Here


        if (logger.isTraceEnabled()) {
            logger.trace("Begin to build %s", templateClass.getKey());
            start = System.currentTimeMillis();
        }
        try {
            RythmEngine engine = engine();
            parser.parse();
            String key = templateClass.getKey();
            if (!key.endsWith("/__global.rythm")) {
                boolean enableGlobalInclude = true;
                if (null != requiredDialect) {
View Full Code Here

        if (empty(o)) return RawData.NULL;
        Escape escape;
        if (null != template) {
            escape = template.__curEscape();
        } else {
            RythmEngine engine = RythmEngine.get();
            if (null != engine) {
                escape = engine.conf().defaultCodeType().escape();
            } else {
                escape = Escape.RAW;
            }
        }
        return escape.apply(o);
View Full Code Here

        if (o instanceof Date) return format(template, (Date) o, pattern, locale, timezone);
        if (o instanceof Number) return format(template, (Number) o, pattern, locale);
        if (null == locale) {
            locale = I18N.locale(template);
        }
        RythmEngine engine = null == template ? RythmEngine.get() : template.__engine();
        if (null == engine) return o.toString();
        for(IFormatter fmt: engine.extensionManager().formatters()) {
            String s = fmt.format(o, pattern, locale, timezone);
            if (null != s) {
                return s;
            }
        }
View Full Code Here

                args = args0;
                useFormat = args.length > 0;
            }
        }
        if (null == locale) locale = I18N.locale(template);
        RythmEngine engine = null == template ? RythmEngine.get() : template.__engine();
        String cacheKey = null;
        if (null != template && null != locale) {
            cacheKey = CacheKey.i18nMsg(template, key, useFormat, locale);
            Object cached = engine.cached(cacheKey);
            if (S.notEmpty(cached)) return S.str(cached);
        }
        ResourceBundle bundle;
        for (String msgSrc: RythmConfiguration.get().messageSources()) {
            bundle = I18N.bundle(template, msgSrc, locale);
            if (null != bundle) {
                String data = getMessage(template, bundle, key, locale, args);
                if (null != data) {
                    if (null != engine) {
                        engine.cache(cacheKey, data, -1);
                    }
                    return data;
                }
            }
        }
View Full Code Here

        if (blackList.contains(tmplName)) {
            //logger.info(">>> %s is in the black list", tmplName);
            return null;
        }
        TemplateClass tc = null;
        RythmEngine engine = this.engine;
        for (ITemplateResourceLoader loader : loaders) {
            tc = loader.tryLoadTemplate(tmplName, engine, callerClass);
            if (null != tc) {
                break;
            }
View Full Code Here

        if (!resource.isValid()) return null;
        String key = S.str(resource.getKey());
        if (typeInference) {
            key += ParamTypeInferencer.uuid();
        }
        RythmEngine engine = this.engine;
        TemplateClass tc = engine.classes().getByTemplate(key);
        if (null == tc) {
            tc = new TemplateClass(resource, engine);
        }
        tc.asTemplate(engine);
        return tc;
View Full Code Here

     * is returned
     *
     * @return the configuration instance associated with engine running in the current thread
     */
    public static RythmConfiguration get() {
        RythmEngine engine = RythmEngine.get();
        return null != engine ? engine.conf() : EMPTY_CONF;
    }
View Full Code Here

     * Render and return result in String. This method is usually called from API defined in
     * {@link RythmEngine}
     */
    @Override
    public final String render() {
        RythmEngine engine = __engine();
        boolean engineSet = RythmEngine.set(engine);
        try {
            long l = 0l;
            boolean logTime = __logTime();
            if (logTime) {
                l = System.currentTimeMillis();
            }

            __triggerRenderEvent(RythmEvents.ON_RENDER, engine);
            __setup();
            if (logTime) {
                __logger.debug("< preprocess [%s]: %sms", getClass().getName(), System.currentTimeMillis() - l);
                l = System.currentTimeMillis();
            }
            try {
                String s = __internalRender();
                return s;
            } finally {
                __triggerRenderEvent(RythmEvents.RENDERED, engine);
                if (logTime) {
                    __logger.debug("<<<<<<<<<<<< [%s] total render: %sms", getClass().getName(), System.currentTimeMillis() - l);
                }
            }
        } catch (ClassReloadException e) {
            engine.restart(e);
            return render();
        } finally {
            if (engineSet) {
                RythmEngine.clear();
            }
View Full Code Here

                    _size = 0;
                    iterator = Collections.EMPTY_LIST.iterator();
                    return;
                }
                List<String> seps = new ArrayList<String>();
                RythmEngine engine = RythmEngine.get();
                RythmConfiguration conf = engine.conf();
                if ("zh".equals(conf.locale().getLanguage())) {
                    seps.addAll(Arrays.asList("\n,、,,,;,。,:".split(",")));
                } else {
                    seps.add("\n");
                }
View Full Code Here

TOP

Related Classes of org.rythmengine.RythmEngine

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.