Package freemarker.template

Examples of freemarker.template.TemplateException$PrintStreamStackTraceWriter


                    unresolvedParamNames = new LinkedList<String>();
                }
                unresolvedParamNames.add(paramName);
            }
            else {
                throw new TemplateException("Missing required parameter " + paramName, env);
            }
        }
        if(unresolvedParamNames != null) {
            // Create a scope that provides live access to the parameter list
            // so we can reference already defined parameters
            Scope scope = new NamedParameterMapScope(env.getCurrentScope(),
                    result);
            fillInDefaults(env, scope, unresolvedParamNames);
        }
        SimpleHash catchAllMap = null;
        if (catchall != null) {
            catchAllMap = new SimpleHash();
            result.put(catchall, catchAllMap);
        }
        if (!argsMap.isEmpty()) {
            if(catchall != null || curryGenerated) {
                for (Map.Entry<String, Expression> entry : argsMap.entrySet()) {
                    Expression exp = entry.getValue();
                    TemplateModel val = exp.getAsTemplateModel(env);
                    assertIsDefined(val, exp, env);
                    if(curryGenerated) {
                        result.put(entry.getKey(), val);
                    } else {
                        catchAllMap.put(entry.getKey(), val);
                    }
                }
            } else {
                throw new TemplateException("Extraneous parameters " +
                        argsMap.keySet() + " provided.", env);
            }
        }
        return result;
    }
View Full Code Here


        TemplateModel tm = nameExp.getAsTemplateModel(env);
        if (tm == Macro.DO_NOTHING_MACRO) return; // shortcut here.
        if (tm instanceof Macro) {
            Macro macro = (Macro) tm;
            if (macro.isFunction()) {
                throw new TemplateException("Routine " + macro.getName()
                        + " is a function. A function can only be called " +
                        "within the evaluation of an expression.", env);
            }   
            env.render(macro, args, bodyParameters, nestedBlock);
        }
        else if (tm instanceof TemplateDirectiveModel) {
            Map<String, TemplateModel> argMap
                    = args != null
                            ? args.getParameterMap(tm, env)
                            : new HashMap<String, TemplateModel>();
            List<String> paramNames;
            if(bodyParameters == null) {
                paramNames = Collections.emptyList();
            }
            else {
                paramNames = bodyParameters.getParamNames();
            }
            env.render(nestedBlock, (TemplateDirectiveModel) tm, argMap, paramNames);
        }
        else if (tm instanceof TemplateTransformModel) {
            Map<String, TemplateModel> argMap
                    = args != null
                            ? args.getParameterMap(tm, env)
                            : new HashMap<String, TemplateModel>();
            env.render(nestedBlock, (TemplateTransformModel) tm, argMap);
        }
        else {
            assertNonNull(tm, nameExp, env);
            throw new TemplateException(getStartLocation() + ": " + nameExp +
                    " is not a user-defined directive.", env);
        }
    }
View Full Code Here

TOP

Related Classes of freemarker.template.TemplateException$PrintStreamStackTraceWriter

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.